Jump to content

While loop: show subcategories, and display by name.


Lucagiaicheca

Recommended Posts

Hello everybody, I need help in coding.

 

this i my category scheme:

 

Authors

- John

- Alex

- Billie

- Shon

- Don't want to display

 

In a CMS page, I need to list all of them (they are a lot), and the listed names need to be links to the categories they refer to. So, if I click con John, I will be sent to john cat page (listing all his books).

 

Of course I need them to be sorted by name.

 

I know I need to take cat with common parent category, make a while cycle to display them (but I would need them sorted by name, it sound impossible to me), but I don't know how to do it...

 

Can you help?

Link to comment
Share on other sites

I managed displaying authors, using category.tpl.

 

Now I cannot sort them by name (I could use arrows in backoffice, but it would take very long).

 

Any suggestion?

 

Here is the code:

{if isset($subcategories)}
		
		<div id="subcategories">
			<h3>ELENCO DELLE CATEGORIE</h3>
			<ul class="inline_list">
			{foreach from=$subcategories item=subcategory}
				<li class="clearfix">
					<!--<a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}" class="img">
						{if $subcategory.id_image}
							<img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium_default')}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
						{else}
							<img src="{$img_cat_dir}default-medium_default.jpg" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
						{/if}
					</a>-->
					{if $subcategory.name!="Catalogo"}
					<a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" class="cat_name">{$subcategory.name|escape:'htmlall':'UTF-8'}</a>
					{if $subcategory.description}
						<p class="cat_desc">{$subcategory.description}</p>
					{/if}{/if}
				</li>
			{/foreach}
			</ul>
			<br class="clear"/>
		</div>
		{/if}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...