MENU

Group Company Directory items in alphabetical order and add shortcuts

  Previous article Next article  

The Company Directory module is good to show an overview 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



Buy Me A Coffee


  Comment Form

ReviewManager

Click here to open the form

ReviewManager

  0 Comments

No comments yet...

Buy Me A Coffee

CMS Made Simple - Tutorials, Tips and Tricks - CMSMS

Group Company Directory items in alphabetical order and add shortcuts

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.19
  Last updated: 29-03-2021
  Comments: 0
  http://cms.ms/JkSH


Buy Me A Coffee




Advertisement


Ads help me to help you! Thanks!

Ads help me to help you! Buy products from these advertisers!