Solved

Cleared div - can't find the source

Posted on 2013-01-27
12
144 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
  • 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Responsive CSS question 2 42
SVG Logo 4 20
Simple Angular 2 login page 4 15
Bootstrap more than 12 columns in row 3 6
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now