Quick PHP Question

Discussion in 'PHP' started by fordP, Jun 27, 2007.

  1. #1
    So I have this piece of code that pulls some category names from an array... I want to put the categories where it will show two categories, and then a line break, and then two more categories..

    Using the code in and around, would it be possible to make a line break after two categories are shown.

    {if $pagename eq 'published' || $pagename eq 'upcoming'}
    {******Get the parent category******}
    	{assign var=requested_cat value=$request_category}
    	
    	{* if story page - set the story's category to this *}
    	{if $pagename eq 'story'}
    	
    		{assign var=requested_cat value='sub'}
    	{/if}
    	
    	{assign var=mainCatStr value=''}
    	{assign var=parentCat value=-1}
    	{section name=thecat loop=$cat_array}
    		{if $cat_array[thecat].safename eq $requested_cat}
    			{if $cat_array[thecat].parent neq 0}
    				{assign var=parentCat value=$cat_array[thecat].parent}
    				{assign var=mainCatStr value=$cat_array[$parentCat].safename}
    			{else}
    				{assign var=parentCat value=$cat_array[thecat].auto_id}
    				{assign var=mainCatStr value=$cat_array[thecat].safename}
    			{/if}
    		{/if}
    	{/section}
    	
    {********* Displaying the Main categories *******************}
    	<div style="border-bottom:1px solid #ccc;padding-bottom:4px">
    	{section name=thecat loop=$cat_array}
    
    		{if $cat_array[thecat].parent eq 0}
    			{if $cat_array[thecat].safename eq $requested_cat || $cat_array[thecat].auto_id eq $parentCat}
    			[B][COLOR="Red"]<a href="{$URL_maincategory, $cat_array[thecat].safename}" class="current">{$cat_array[thecat].name}</a>[/COLOR][/B]
    			{elseif $requested_cat eq "" && $cat_array[thecat].auto_id eq 0}
    				[B][COLOR="Red"]<a href="{$URL_maincategory, $cat_array[thecat].safename}" class="current">{$cat_array[thecat].name}</a>[/COLOR][/B]
    			{else}
    				[B][COLOR="Red"]<a href="{$URL_maincategory, $cat_array[thecat].safename}">{$cat_array[thecat].name}</a>[/COLOR][/B]
    			{/if}
    		{/if}
    		
    	{/section}</div>
    	<br/>
    	{********* Displaying the Sub categories *******************}
    	<span>
    	{if $parentCat gt 0}
    	<ul>
    		<div style="border-bottom:1px solid #ccc;padding-bottom:4px">
    		{if $requested_cat eq $mainCatStr}
    			
    			{else}
    		
    				<li><a href="{$URL_maincategory, $mainCatStr}">{#PLIGG_Visual_RSS_All#}</a></li>
    			{/if}
    			{section name=thecat loop=$cat_array}
    				{if $cat_array[thecat].parent eq $parentCat}
    					{if $cat_array[thecat].safename eq $requested_cat}
    						<li><a href="{$cat_url}{$cat_array[thecat].safename}" class="current">{$cat_array[thecat].name}</a></li>
    				{else}
    						<li><a href="{$cat_url}{$cat_array[thecat].safename}">{$cat_array[thecat].name}</a></li>
    					{/if}
    				{/if}
    			{/section}
    		</div>
    		</ul>
    	{/if}</span>
    	
    	
    	{elseif $pagename neq 'submit'}
    	{********* Displaying the Main categories *******************}
    	<div style="border-bottom:1px solid #ccc;padding-bottom:4px">
    	{section name=thecat loop=$cat_array}
    	
    		{if $cat_array[thecat].parent eq 0}
    			<a href="{$URL_maincategory, $cat_array[thecat].safename}">{$cat_array[thecat].name}</a>
    		{/if}
    	{/section}
    Code (markup):
    Shouldn't I be able to take $cat_array[thecat].safename and tell it to insert a line break after 2 categories are displayed?
     
    fordP, Jun 27, 2007 IP
  2. xxKillswitch

    xxKillswitch Peon

    Messages:
    331
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    That is PHP? Are you sure you are posting in the right forum?
     
    xxKillswitch, Jun 28, 2007 IP
  3. chopsticks

    chopsticks Active Member

    Messages:
    565
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Smarty by the looks of it (maybe wrong), but if so then it is in the right forum.
     
    chopsticks, Jun 28, 2007 IP
  4. fordP

    fordP Peon

    Messages:
    548
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It's smarty.

    It's still pretty easy to see what is going on.
     
    fordP, Jun 28, 2007 IP
  5. xxKillswitch

    xxKillswitch Peon

    Messages:
    331
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ah ok, I thought it looked kinda strange. Sorry, never dealt with Smarty before.
     
    xxKillswitch, Jun 28, 2007 IP