Improperly Formatted Categories - Looking for a pointer
Moderator: Thorsten
-
- Posts: 7
- Joined: Tue Oct 16, 2012 3:22 pm
Improperly Formatted Categories - Looking for a pointer
Hello. I am taking over a theme that was modified by a previous employee, and I've noticed something odd about the display format for categories.
If I add multiple subcategories, eventually they start displaying improperly, as if they are not nested within their parent category but rather on the same level as their parent.
My previous employee modified the admin layout, so the problem is occurring there as well as in the themed front-end layout.
If I revert the front-end to the default layout, the Show All Categories listing is formatted properly.
I cannot seem to find the code where this is happening. Could someone point me in the proper direction?
Admin Panel - Themed/Modified
Front End - Default Theme
In the modified layout, I can swap positions of two categories (say "VoIP" and "Client Support") and they still display improperly ("VoIP would then be on the same level as "Harbor Corporate KB" and "Client Support" would be properly nested under "Harbor Corporate KB"). I am not using cut and paste, however I have tried that as well and they still display improperly.
Any ideas as to where this is going wrong?
Best regards,
--Jason
If I add multiple subcategories, eventually they start displaying improperly, as if they are not nested within their parent category but rather on the same level as their parent.
My previous employee modified the admin layout, so the problem is occurring there as well as in the themed front-end layout.
If I revert the front-end to the default layout, the Show All Categories listing is formatted properly.
I cannot seem to find the code where this is happening. Could someone point me in the proper direction?
Admin Panel - Themed/Modified
Front End - Default Theme
In the modified layout, I can swap positions of two categories (say "VoIP" and "Client Support") and they still display improperly ("VoIP would then be on the same level as "Harbor Corporate KB" and "Client Support" would be properly nested under "Harbor Corporate KB"). I am not using cut and paste, however I have tried that as well and they still display improperly.
Any ideas as to where this is going wrong?
Best regards,
--Jason
-
- Posts: 7
- Joined: Tue Oct 16, 2012 3:22 pm
Re: Improperly Formatted Categories - Looking for a pointer
Ok, after further digging today, I realize this is *only* happening within the admin panel. The themed front-end is working fine.
I also found the section of code that includes the for loop which generates the category tree listing. I'm not certain where in this code the problem may lie, however.
Would anyone be able to assist, please?
Best regards,
--Jason
I also found the section of code that includes the for loop which generates the category tree listing. I'm not certain where in this code the problem may lie, however.
Would anyone be able to assist, please?
Code: Select all
foreach ($category->catTree as $cat) {
$indent = '';
for ($i = 0; $i < $cat['indent']; $i++) {
$indent .= ' ';
}
// Category translated in this language?
if ($cat['lang'] == $lang) {
$categoryName = $cat['name'];
} else {
$categoryName = $cat['name'] . ' (' . $languageCodes[strtoupper($cat['lang'])] . ')';
}
$level = $cat['level'];
$leveldiff = $open - $level;
if ($leveldiff > 1) {
print '</li>';
for ($i = $leveldiff; $i > 1; $i--) {
printf(
"\n%s</ul>\n%s</li>\n</div>\n",
str_repeat("\t", $level + $i + 1),
str_repeat("\t", $level + $i)
);
}
}
if ($level < $open) {
if (($level - $open) == -1) {
print '</li>';
}
print "\n".str_repeat("\t", $level + 2)."</ul>\n".str_repeat("\t", $level + 1)."</li>\n";
} elseif ($level == $open && $y != 0) {
print "</li>\n";
}
if ($level > $open) {
printf('<div id="div_%d" style="display: none;">', $lastCatId);
printf("\n%s<ul>\n%s<li>",
str_repeat("\t", $level + 1),
str_repeat("\t", $level + 1));
} else {
print str_repeat("\t", $level + 1)."<li>";
}
if (count($category->getChildren($cat['id'])) != 0) {
// Show name and icon for expand the sub-categories
printf(
"<strong><a href=\"javascript:;\" onclick=\"toggleFieldset('%d');\">%s</a></strong> ",
$cat['id'],
$categoryName
);
} else {
// Show just the name
printf("<strong>%s</strong> ", $categoryName);
}
if ($cat["lang"] == $lang) {
// add sub category (if current language)
printf('
<a href="?action=addcategory&cat=%s&lang=%s"><img src="images/add.png" width="16" height="16" alt="%s" title="%s" border="0" /></a> ',
$cat['id'],
$cat['lang'],
$PMF_LANG['ad_quick_category'],
$PMF_LANG['ad_quick_category']
);
// rename (sub) category (if current language)
printf('
<a href="?action=editcategory&cat=%s"><img src="images/edit.png" width="16" height="16" border="0" title="%s" alt="%s" /></a> ',
$cat['id'],
$PMF_LANG['ad_kateg_rename'],
$PMF_LANG['ad_kateg_rename']
);
}
// translate category (always)
printf(
'<a href="?action=translatecategory&cat=%s"><img src="images/translate.png" width="16" height="16" border="0" title="%s" alt="%s" /></a> ',
$cat['id'],
$PMF_LANG['ad_categ_translate'],
$PMF_LANG['ad_categ_translate']
);
// delete (sub) category (if current language)
if (count($category->getChildren($cat['id'])) == 0 && $cat["lang"] == $lang) {
printf(
'<a href="?action=deletecategory&cat=%s&catlang=%s"><img src="images/delete.png" width="16" height="16" alt="%s" title="%s" border="0" /></a> ',
$cat['id'],
$cat['lang'],
$PMF_LANG['ad_categ_delete'],
$PMF_LANG['ad_categ_delete']
);
}
if ($cat["lang"] == $lang) {
// cut category (if current language)
printf(
'<a href="?action=cutcategory&cat=%s"><img src="images/cut.png" width="16" height="16" alt="%s" border="0" title="%s" /></a> ',
$cat['id'],
$PMF_LANG['ad_categ_cut'],
$PMF_LANG['ad_categ_cut']
);
if ($category->numParent($cat['parent_id']) > 1) {
// move category (if current language) AND more than 1 category at the same level)
printf(
'<a href="?action=movecategory&cat=%s&parent_id=%s"><img src="images/move.gif" width="16" height="16" alt="%s" border="0" title="%s" /></a>',
$cat['id'],
$cat['parent_id'],
$PMF_LANG['ad_categ_move'],
$PMF_LANG['ad_categ_move']
);
}
}
$open = $level;
$lastCatId = $cat['id'];
}
--Jason
-
- Posts: 7
- Joined: Tue Oct 16, 2012 3:22 pm
Re: Improperly Formatted Categories - Looking for a pointer
Disregard the last post, perhaps. I ran the Compare plugin from Notepad++ against category.main.php and a copy from the original category.main.php file from the download of phpMyFAQ, and there were no discrepencies.
I'm at a loss currently. I'm going to take the original admin panel and put it in place of the modified one I've been working with and see how things react there. If anyone is able to lend a hand, it would be gratefully appreciated!
Best regards,
--Jason
I'm at a loss currently. I'm going to take the original admin panel and put it in place of the modified one I've been working with and see how things react there. If anyone is able to lend a hand, it would be gratefully appreciated!
Best regards,
--Jason
Re: Improperly Formatted Categories - Looking for a pointer
Hi,
I was on vacation, I'll check it.
bye
Thorsten
I was on vacation, I'll check it.
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist
-
- Posts: 7
- Joined: Tue Oct 16, 2012 3:22 pm
Re: Improperly Formatted Categories - Looking for a pointer
Thanks, Thorsten.
Yesterday, I rename my /admin directory to /admin.bak, and then I took an unmodified copy of the /admin directory straight from the phpMyFAQ archive and put it in place on my system. I still received the same error in unordered list indenting.
I am now assuming that it's pulling the code from outside of the /admin directory, but again I am at a loss as to where to look. I'm still trying to pick it apart as I have time, but help is most definitely appreciated!
Best regards,
--Jason
Yesterday, I rename my /admin directory to /admin.bak, and then I took an unmodified copy of the /admin directory straight from the phpMyFAQ archive and put it in place on my system. I still received the same error in unordered list indenting.
I am now assuming that it's pulling the code from outside of the /admin directory, but again I am at a loss as to where to look. I'm still trying to pick it apart as I have time, but help is most definitely appreciated!
Best regards,
--Jason
-
- Posts: 7
- Joined: Tue Oct 16, 2012 3:22 pm
Re: Improperly Formatted Categories - Looking for a pointer
If this helps any, I'm using FireBug/FirePHP in FireFox to get a look at what is happening.
Clearly, the category "Harbor Corporate KB" is assigned an id of 15.
"Project Management" and "Client Support" are both listing their 'parent_id' as 15, but something in the code is not indenting them properly to show them as subcategories of their parent.
Clearly, the category "Harbor Corporate KB" is assigned an id of 15.
"Project Management" and "Client Support" are both listing their 'parent_id' as 15, but something in the code is not indenting them properly to show them as subcategories of their parent.
Code: Select all
<li>
<strong>
<a onclick="toggleFieldset('15');" href="javascript:;">Harbor Corporate KB</a>
</strong>
<a href="?action=addcategory&cat=15&lang=en">
<img width="16" height="16" border="0" title="Add new category" alt="Add new category" src="images/add.png">
</a>
<a href="?action=editcategory&cat=15">
<img width="16" height="16" border="0" alt="Rename" title="Rename" src="images/edit.png">
</a>
<a href="?action=translatecategory&cat=15">
<img width="16" height="16" border="0" alt="Translate" title="Translate" src="images/translate.png">
</a>
<a href="?action=cutcategory&cat=15">
<a href="?action=movecategory&cat=15&parent_id=0">
<div id="div_15" style="">
<ul>
<li>
<strong>VoIP</strong>
<a href="?action=addcategory&cat=23&lang=en">
<a href="?action=editcategory&cat=23">
<a href="?action=translatecategory&cat=23">
<a href="?action=deletecategory&cat=23&catlang=en">
<a href="?action=cutcategory&cat=23">
<a href="?action=movecategory&cat=23&parent_id=15">
</li>
<li>
<li>
<li>
<li>
<li>
</ul>
</div>
</li>
<li>
<strong>Project Management</strong>
<a href="?action=addcategory&cat=39&lang=en">
<a href="?action=editcategory&cat=39">
<a href="?action=translatecategory&cat=39">
<a href="?action=deletecategory&cat=39&catlang=en">
<a href="?action=cutcategory&cat=39">
<a href="?action=movecategory&cat=39&parent_id=15">
</li>
<li>
<strong>Client Support</strong>
<a href="?action=addcategory&cat=40&lang=en">
<a href="?action=editcategory&cat=40">
<a href="?action=translatecategory&cat=40">
<a href="?action=deletecategory&cat=40&catlang=en">
<a href="?action=cutcategory&cat=40">
<a href="?action=movecategory&cat=40&parent_id=15">
</li>
Re: Improperly Formatted Categories - Looking for a pointer
Hi,
which version do you use? I think I fixed that in one of the latest versions.
bye
Thorsten
which version do you use? I think I fixed that in one of the latest versions.
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist
-
- Posts: 7
- Joined: Tue Oct 16, 2012 3:22 pm
Re: Improperly Formatted Categories - Looking for a pointer
Thorsten, you know what? I sincerely apologize.
I'm not sure why I didn't look at that first. I've been thinking I'm already running the latest version, but I am still on phpMyFAQ 2.7.4.
I will attempt the upgrade to 2.7.8 and see if the matter is resolved.
Best regards,
--Jason
I'm not sure why I didn't look at that first. I've been thinking I'm already running the latest version, but I am still on phpMyFAQ 2.7.4.
I will attempt the upgrade to 2.7.8 and see if the matter is resolved.
Best regards,
--Jason
Re: Improperly Formatted Categories - Looking for a pointer
Hi,
perfect! First I didn't remembered this bug because it was so awful to fix in the beginning. Glad it's fixed for you now, too!
bye
Thorsten
perfect! First I didn't remembered this bug because it was so awful to fix in the beginning. Glad it's fixed for you now, too!
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist
-
- Posts: 7
- Joined: Tue Oct 16, 2012 3:22 pm
Re: Improperly Formatted Categories - Looking for a pointer
You are indeed correct, Thorsten! After updating to 2.7.8 it is working as intended.
Again, my apologies for not recognizing I needed to try this first. Thank you for your help.
Best regards,
--Jason
Again, my apologies for not recognizing I needed to try this first. Thank you for your help.
Best regards,
--Jason