UName10
asked on
Cleared div - can't find the source
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:
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"-->
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.
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?
ASKER
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.
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.
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?
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.
my instinct tells me it would be solved by using:
cint((total+1)/2)
(instead of just total/2).
ASKER
Thank you very much for the response, I've just tried the following for line 94:
It didn't work unfortunately...thanks again for the help.
if cint((total+1)/2) then %>
It didn't work unfortunately...thanks again for the help.
You took out the first part as well, I meant only replace total/2:
if (i+1) > cint((total+1)/2) then %>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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):
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.
if intCurCol < 1 And i > cint((total-1)/2) Then
intCurCol = intCurCol + 1 %>
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.
ASKER
Hi Robert, I went with the simple solution for now, but I'll certainly check the others after:
Thanks very much for the help!
if (i+1) > cint(total/2) then %>
Thanks very much for the help!