Solved

Cleared div - can't find the source

Posted on 2013-01-27
12
185 Views
Last Modified: 2013-05-12
The business directory page here has the last category & subcats that seem to have cleared both - 'Wedding Services', whereas it needs to be a continuation and I'm not sure why.

If anyone could spot it that would be great:

<!--#include virtual="/System/Startup_Public.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><%=server.HTMLEncode(Session("PublicFranchiseName"))%> Business Directory - Local <%=server.HTMLEncode(Session("PublicFranchiseName"))%> Businesses, Essex. <%=(Session("PublicFranchiseName"))%> Restaurants, Shopping, Plumbers and More.</title>
<meta name="Description" content="<%=server.HTMLEncode(Session("PublicFranchiseName"))%> Business Directory of Local Businesses, Essex.  Detailed <%=server.HTMLEncode(Session("PublicFranchiseName"))%> business lisitngs, full business contact details and links to local maps." />
<meta content="<%=server.HTMLEncode(Session("PublicFranchiseName"))%> businesses, <%=server.HTMLEncode(Session("PublicFranchiseName"))%> business directory, <%=server.HTMLEncode(Session("PublicFranchiseName"))%> restaurants, <%=server.HTMLEncode(Session("PublicFranchiseName"))%> plumbers, <%=server.HTMLEncode(Session("PublicFranchiseName"))%> electricians, <%=server.HTMLEncode(Session("PublicFranchiseName"))%> shops and shopping" name="Keywords" />
<!--#include virtual="/Assets/Templates/Public/Franchise/HeadCSS.asp"-->
<%
strTemplate_Option_Content_LeftMargin_Width = 6
strTemplate_Option_Content_RightMargin_Width = 0
%>

<script type="text/javascript">
jQuery.noConflict();

	function updatesubcat() {
		$category = $('topcat').options[$('topcat').selectedIndex].value;
		PagetoDiv("/ajax/home_subcategory.asp?c="+$category,"subcategory");
	}
</script>
</head>
<body id="directory">
<!--#include virtual="/Assets/Templates/Public/Franchise/Directory.asp"-->
    <%
	sqlCommand = "SELECT GID,DirectoryName,DirectoryIcon,LinkDescription,dbo.RemoveNonAlphaCharacters(DirectoryName) as URL "&_
		" FROM Directories "&_ 
		"WHERE OpenDate < GETDATE() AND "&_
		"Approved = 1 "&_
		"AND (FranchiseGID IS NULL OR FranchiseGID = '"&Session("PublicFranchiseGID")&"') "&_
		"AND (NOT GID = '2d81c28f-95e1-48bd-92ff-b57896b8d516') "&_
		"AND ParentDirectoryGID IS NULL ORDER BY DirectoryName;"	
	
	getrs Directories,sqlCommand,""
	total = 0
	while not Directories.eof
		sqlCommand = "GetAllDirectories '" & Session("PublicFranchiseGID") & "', '" & Directories("GID") & "',1"
		'sqlCommand = "AdvertCount '" & Directories("GID") & "','" & Session("PublicFranchiseGID") & "'"
		response.write "<!-- ssql "&sqlcommand &" -->"
		getrs subcat,sqlCommand,""
		if not subcat.eof then total = total + 1
	Directories.movenext
	wend
	Directories.requery
		response.write "<!-- total "&total &" -->"
	i = 0
	%>
      <div id="dir-left" style="clear:both">
    	<% while not Directories.eof 

		sqlCommand = "GetAllDirectories '" & Session("PublicFranchiseGID") & "', '" & Directories("GID") & "',1"
		
		getrs subcat,sqlCommand,"" 
		if not subcat.eof then
		%>
            <div class="bus-dir clearfix">
            	 <div class="bus-dir-header"><div class="logo">
                    <% if len(""&Directories("DirectoryIcon")) > 0 then %>
                      <%=Directories("DirectoryIcon")%>
                    <% end if %>
                 </div>
               <h3><a href="/<%=lcase(Session("PublicFranchiseName"))%>/<%=Directories("URL")%>.html"><%=server.HTMLEncode(Directories("DirectoryName"))%></a></h3>
                </div>
                    <div class="subcats">
                    <% caturl = Directories("URL")
                    slen = 0
                    while not subcat.eof 
					
						sLink = "/" & lcase(Session("PublicFranchiseName"))
						getrs tmp,"USP_Helper_GetDirectoryHierarchy '" & subcat("GID") & "'",""
						while not tmp.eof 
							sLink = sLink & "/" & tmp("URL")
						tmp.movenext
						wend
						tmp.close
						set tmp = nothing
						sLink = sLink & ".html"
					
						subgid = replace(subcat("GID"),"{","")
						subgid = replace(subgid,"}","") 				
						if slen < 800 then %>
							<a href="<%=sLink%>"><%=server.HTMLEncode(subcat("DirectoryName"))%></a><%
						end if 'slen
						slen = slen + len(subcat("Directoryname"))
						subcat.movenext
                     
                    wend %>
                    </div>
            </div>
        <% 
			i = i+1
			end if 'subcat.eof
			if (i+1) > (total/2) then %>
                </div><div id="dir-right">
                <% i = 0
			end if
			Directories.movenext
		wend %>
		</div>
<div style="clear:both;"></div>
<!--#include virtual="/Assets/Templates/Public/Franchise/TemplateEnd.asp"-->
</body>
</html>
<!--#include virtual="/System/Shutdown.asp"-->

Open in new window

0
Comment
Question by:UName10
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 3
12 Comments
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 38825087
There's a 'left' part and a 'right' part, then another 'right' part with the one category. The problem is probably in the php. Could it be the classic 'divide by 2' problem? if you show half the categories sometimes the logic is flawed: 5 / 2 = 2 (for example) and the last item doesn't fit the loop, maybe a mod calculation is used to start a new 'right' part and that is called twice.
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 38825102
I did a 'view source' and pasted it in Visual Web Developer, there seems to be a </div> missing at the end. That may be another symptom of the problem I suspect. If this is in fact a static page then you should be able to just move the whole category div inside the 'right' part div.
capture
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 38898536
Hi, if I look at the page on your website now, it seems the problem is solved. Can you confirm if my suggestion got you to the solution?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:UName10
ID: 39147858
Hi Robert,

Very sorry for the delay.

Unfortunately the problem is still there! It's not the footer area as all divs are closed and it's the same on every page. I'm really not sure what's causing it, but I have a feeling it might be the asp that handles the directory in the admin section which is a whole new ballgame.

I think I'll get my developer to fix it or it'll be a nightmare to diagnose, many thanks for the help and apologies again for the delay.
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39147954
As I stated in my previous comment, at some point it seemed to be solved, but it's possible (like I described earlier) that adding/removing a category causes the problem to disappear and resurface (you could test that by adding a dummy category?). A developer should indeed be able to find a mistake like that (outputting a third 'column' when the number of categories is uneven for example) in the code. If not, try to convince them to let you post part of the code (assuming there is some server side processing?) and maybe I can provide some more help with that. There should be something like a loop reading the categories from the database, if that's how it's done. Maybe everything is put in an array, then that code could be the culprit. It could also be code that generates the html page?
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39148031
Wait, this is embarrasing! I see you already posted the ASP! Look at line 94, this must be cause for that extra 'column'. I would need to test it out to be sure but the test on that line is probably wrong, this should only happen once whereas in the current situation it happens twice.
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39148045
my instinct tells me it would be solved by using:
cint((total+1)/2)

Open in new window

(instead of just total/2).
0
 

Author Comment

by:UName10
ID: 39151021
Thank you very much for the response, I've just tried the following for line 94:

if cint((total+1)/2) then %> 

Open in new window


It didn't work unfortunately...thanks again for the help.
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39151053
You took out the first part as well, I meant only replace total/2:
if (i+1) > cint((total+1)/2) then %>

Open in new window

0
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 300 total points
ID: 39151100
After testing it seems better (to get an even distribution) to use:
if (i+1) > cint(total/2) then %>

Open in new window

Actually I think the code should be rewritten to make sure this is only called once, but it should work this way, whether there are an even number of categories or not (which I still think is the main problem with the original code). It can still output the extra div, but empty.

EDIT: Moving the check part to the start of the while solves that by the way.
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39151229
A check to output this part only once could be added like this for example (using integer instead of boolean to leave room to one day change it to more columns):
			if intCurCol < 1 And i > cint((total-1)/2) Then
				intCurCol = intCurCol + 1 %>

Open in new window

Sorry for using yet another check for the 'middle point', been playing around with this...

An even better solution would be to calculate that middle point by looking at the number of subcategories of course. Would you be interested in that?

There are also very nice solutions using client side javascript for a nicer distribution of the categories.
0
 

Author Comment

by:UName10
ID: 39159443
Hi Robert, I went with the simple solution for now, but I'll certainly check the others after:

 
if (i+1) > cint(total/2) then %>

Open in new window


Thanks very much for the help!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question