Group Company Directory items in alphabetical order and add shortcuts

  Previous article Next article  

Group Company Directory items in alphabetical order and add shortcuts

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.2
  Last updated: 14-07-2016
  Comments: 0

The Company Directory module is great to show a survey of companies and contacts at your CMS Made Simple™ website.

With a little adjustment to the summary template you can group the output in alphabetical order and add shortcuts to the entries.

  How to use

Add to the top of your summary template:

{$initial = ''}
{$stored_initial = ''}

<p><b>Directly to initial: </b>
{foreach from=$items item=entry}
  {if $entry->company_name[0]|lower != $initial}
    {$initial = $entry->company_name[0]|lower}
    <b><a href="{$page_alias}#{$initial}">{$initial|upper}</a></b>&nbsp;
  {/if}
{/foreach}
</p>

And add directly after the {foreach ...} 5 new lines:

{if isset($items)}
  {foreach from=$items item=entry}

    {if $entry->company_name[0]|lower != $stored_initial}
      <a name="{$entry->company_name[0]|lower}"></a>
      <h3>{$entry->company_name[0]|upper}</h3>
      {$stored_initial = $entry->company_name[0]|lower}
    {/if}

    <article class="CompanyDirectoryItem" style="padding-bottom: 2em;">
      <div class="row">
      ...
      ...
  {/foreach}
{/if}

  Working example



A2 Webhosting CMS Made Simple

  Comments

  Click here to leave a comment






This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)
  « Enter the CAPTCHA code (lower case)

Your IP address will be stored on submit. I reserve the right to change or delete your response without notice!
In case of abuse your IP address will be blocked!


Can I have your attention for a moment?

Did this tutorial help you solving a problem at your (clients) website and it saved you many hours of work? Great!!
Consider buying Rolf a cup of coffee in return! [ Click here ]


  0 Comments

No comments yet...

CMS Made Simple 2.2.2 - Tutorials, tips and tricks - CMSMS 2.2.2

Group Company Directory items in alphabetical order and add shortcuts

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.2
  Last updated: 14-07-2016
  Comments: 0

A2 Webhosting CMS Made Simple