PDA

View Full Version : Simple If Else Help


KartKorner
05-18-2006, 12:35 AM
I have been playing around with what should be a pretty simple db inquiry but have yet to figure out where I am going wrong. Essientially I would like to show some info if there are no subcats within the shown cat (i.e. those cats that have no subcats (0) would look different then those with a number (2)) Here is what I have this time. I have tried numerous variations of this solution but without any current success:
{if $categs gt 0 and $this->cat.SUBCATS.COUNT gt 0}
BLAH...
{else}
BLAH...
{/if}

This will always be false because it has no way to identify which catID to compare the equation too :confused:

KartKorner
05-18-2006, 05:55 PM
I am getting closer but am curious as to why the following behavior occurs: If a category is show on the homepage then all if else and nested if else statements validate but if you have navigated into a subcategory then only portions validate. Below you will see the code that works on the homepage and semi wroks within the individual categories. If a category has either a subcategory or a link within the category then the first if passes but the second if fails. I know I need to include another nested if when the the second foreach but I am right now just trying to successfully enter into the second foreach when inside a subcat. Thanks for all your help.

Code (all from main.tpl):
{foreach from=$categs item=cat name=categs}
{if $cat.COUNT gt 0} //no change needed here
...
{if !empty($cat.SUBCATS)} //works perfectly on homepage but will also be false within subcat so my other nested ifs will never work :(

If I can get the second to authenticate while viewing a subcat with subcats then I should be able to process my nested if else within the nested foreach statement. Let me know if I lost ya'll and thanks for the help...pending secret forum access so have to post here :)

KartKorner
05-18-2006, 07:31 PM
Have since found a "temporary" fix for the whole link count issue. Will better the solution later but atleast for now it is no longer a part of the equation. :)

anon
05-18-2006, 07:55 PM
Content visible to registered users only.
why don't you just

{if !empty($cat.SUBCATS) and $category.ID gt 0}
....there are subcats so we can display them in here
{else}
....there are no subcats 'this is what i want to say when empty'
{/if}

?

...edit for type O in category

KartKorner
05-18-2006, 09:28 PM
The reason I have seperated out the two is because I do use this code on the homepage itself so I need the code to process at the root level. Once that portion has processed it then preceeds to the next portion. I believe the reason the second portion is proving false is because of the way the directory script is set to only allow for the displaying of subcats within the parent root only.

anon
05-18-2006, 10:09 PM
I guess i'm just not following you. I have several nested ifs in one of my directories, which validate whether if they are in a sub-cat and whether or not if there is a sub-cat within that subcat, for as many sub-cats there can ever be.


as an example:
if you surf this..
{malware warning found at this link - removed}©®™


{malware warning found at this link - removed}©®™

here the initial {if} gets hit because there *are* subcat. so !empty=true

{malware warning found at this link - removed}]©®™

here is the {else} put in place gets hit because there *arent* sub-cats. so !empty=false, so now you see 'Suggest a Category'


Maybe I need some clarification as to what you're trying to accomplish on a whole.

KartKorner
05-18-2006, 11:35 PM
Think I figured it out. Well pretty close :)