[SOLVED] Company Directory - alphabetical menu for sorting

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
nosyguy
Forum Members
Forum Members
Posts: 87
Joined: Tue Apr 22, 2008 8:17 pm

[SOLVED] Company Directory - alphabetical menu for sorting

Post by nosyguy »

I've been trying to think of a way to implement a menu for my company directory so they can jump to a listing of companies that begin with a letter of the alphabet.

Basically similar to the module directory - click "A" to see a list of companies that begin with A, etc...

Any suggestions?


-----------
nosyguy
Last edited by nosyguy on Fri Jan 10, 2014 6:28 pm, edited 1 time in total.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Company Directory - alphabetical menu for sorting

Post by Rolf »

I have made that once. Have to look it up tomorrow...
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
nosyguy
Forum Members
Forum Members
Posts: 87
Joined: Tue Apr 22, 2008 8:17 pm

Re: Company Directory - alphabetical menu for sorting

Post by nosyguy »

That would be fantastic - thanks!


----------
nosyguy
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Company Directory - alphabetical menu for sorting

Post by Rolf »

http://www.zeijen.nu/bedrijven

Code: Select all

{assign var=initial value=null}
<p>Directly to first letter:&nbsp;
{foreach from=$items item=entry}
  {if $entry->company_name[0]|strtolower != $initial|strtolower}
    {assign var=initial value=$entry->company_name[0]|strtolower}
    <a href="{$page_alias}#{$initial}">{$initial|upper}</a>&nbsp; 
  {/if}
{/foreach}
</p>

{foreach from=$items item=entry}
  <a name="{$entry->company_name[0]|lower}"></a>

  <!-- Summary template code -->

{/foreach}
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Company Directory - alphabetical menu for sorting

Post by Wishbone »

I could have sworn that CompanyDirectory had this feature.. I accidently got into the alphabetical directory mode for some module very recently, but can't figure out which module it was.. Unless I dreamed the whole thing. :)
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Company Directory - alphabetical menu for sorting

Post by Wishbone »

Oh.. It was CGUserDirectory that had this feature.
nosyguy
Forum Members
Forum Members
Posts: 87
Joined: Tue Apr 22, 2008 8:17 pm

Re: Company Directory - alphabetical menu for sorting

Post by nosyguy »

Rolf,

Thank you so much - I am almost there, but ran into one snag.

The Alphabetical menu shows up fine now, but when I click to go to the listing it always goes to the very first listing instead of down to the alphabetical match.

The example site you sent works great - mine just isn't doing the same thing. The only thing I changed in the code you sent me was to include the full link reference - my template is below:

Code: Select all

{* CompanyDirectory Summary Template *}
{if isset($messages)}
<div class="CompanyDirectoryMessage">
 <ul>
   {foreach from=$messages item='one'}
     <li>{$one}</li>
   {/foreach}
 </ul>
</div>
{/if}

{if isset($errors)}
<div class="CompanyDirectoryError">
 <ul>
   {foreach from=$errors item='one'}
     <li>{$one}</li>
   {/foreach}
 </ul>
</div>
{/if}

{assign var=initial value=null}
<p>Directly to first letter:&nbsp;
{foreach from=$items item=entry}
  {if $entry->company_name[0]|strtolower != $initial|strtolower}
    {assign var=initial value=$entry->company_name[0]|strtolower}
    <a href="index.php/membership/{$page_alias}#{$initial}">{$initial|upper}</a>&nbsp; 
  {/if}
{/foreach}
</p>

{foreach from=$items item=entry}
  <a name="{$entry->company_name[0]|lower}"></a>

  <!-- Summary template code -->

{/foreach}

{if isset($items)}
  {if isset($firstlink) || isset($nextlink)}
    <div>
      {if isset($firstlink)}{$firstlink}&nbsp;{$prevlink}&nbsp;&nbsp;{/if}
      {$pagetext} {$curpage} {$oftext} {$pagecount}
      {if isset($nextlink)}&nbsp;&nbsp;{$nextlink}&nbsp;{$lastlink}{/if}
    </div>
  {/if}
<br />
  {foreach from=$items item=entry}
  <article class="CompanyDirectoryItem" style="padding-bottom: 2em;">
    <div class="row-fluid">
     
      <div class="span10">
<div style="float:left;padding:0 20px 0 0;">
{if $entry->logo_location ne ''}
{CGSmartImage src=$entry->logo_path filter_resize='w,190'}
       {/if}   
</div>
        <div class="row-fluid">
        <a href="{$entry->detail_url}"><h3>{$entry->company_name}</h3></a>
        </div>
        <div class="row-fluid">
          {module_action_link module='CGSocialApp' action='addcheckin' location=$entry->id text='Checkin Here'}
        </div><br />
        {if $entry->address ne ''}
          <div class="row-fluid">{$entry->address}</div>
        {/if}
        {if $entry->website ne ''}
          <div class="row-fluid"><a href="http://{$entry->website}">{$entry->website}</a></div>
        {/if}
      </div>
    </div>
_______________________________________________________________________________

    {* sample of addressing a custom field directly *}
{strip}
    {if isset($entry->fields)}
      {if isset($entry->fields.foo) && $entry->fields.foo->value != ''}
        Foo: {$entry->fields.foo->value}<br/>
      {/if}

      {* sample of addressing a field with spaces or other chars in the name
      Special Field: {assign var='tmp' value='The Field Name'}{$entry->fields.$tmp->value}<br/>
    *}
  
    {* sample of addressing the value of a dropdown field: *}
    {if isset($entry->fields.mydropdown) && $entry->fields.mydropdown->dropdown_value != ''}
      Sample Dropdown: {$entry->fields.mydropdown->dropdown_value}<br/>
    {/if}

    {* sample of looping through the fields associative array
    {foreach from=$entry->fields key='fieldname' item='field'}
      {if isset($field->value) && $field->value != ''}
        {$field->name} <em>({$field->type})</em>: {$field->value}<br/>
      {/if}
    {/foreach}
    *}
  {/if}
{/strip}

  </article>
  {foreachelse}
    <div class="alert alert-error">{$CompanyDirectory->Lang('error_nocompaniesmatch')}</div>
  {/foreach}
{/if}
You can see the page testing at this link:
http://198.104.112.247/~nosyguy9/trista ... -directory

------------
nosyguy
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Company Directory - alphabetical menu for sorting

Post by Rolf »

Code: Select all

{* CompanyDirectory Summary Template *}
{if isset($messages)}
<div class="CompanyDirectoryMessage">
 <ul>
   {foreach from=$messages item='one'}
     <li>{$one}</li>
   {/foreach}
 </ul>
</div>
{/if}

{if isset($errors)}
<div class="CompanyDirectoryError">
 <ul>
   {foreach from=$errors item='one'}
     <li>{$one}</li>
   {/foreach}
 </ul>
</div>
{/if}

{assign var=initial value=null}
<p>Directly to first letter:&nbsp;
{foreach from=$items item=entry}
  {if $entry->company_name[0]|strtolower != $initial|strtolower}
    {assign var=initial value=$entry->company_name[0]|strtolower}
    <a href="index.php/membership/{$page_alias}#{$initial}">{$initial|upper}</a>&nbsp;
  {/if}
{/foreach}
</p>


{if isset($items)}
  {if isset($firstlink) || isset($nextlink)}
    <div>
      {if isset($firstlink)}{$firstlink}&nbsp;{$prevlink}&nbsp;&nbsp;{/if}
      {$pagetext} {$curpage} {$oftext} {$pagecount}
      {if isset($nextlink)}&nbsp;&nbsp;{$nextlink}&nbsp;{$lastlink}{/if}
    </div>
  {/if}
<br />
  {foreach from=$items item=entry}

<a name="{$entry->company_name[0]|lower}"></a>

  <article class="CompanyDirectoryItem" style="padding-bottom: 2em;">
    <div class="row-fluid">
     
      <div class="span10">
<div style="float:left;padding:0 20px 0 0;">
{if $entry->logo_location ne ''}
{CGSmartImage src=$entry->logo_path filter_resize='w,190'}
       {/if}   
</div>
        <div class="row-fluid">
        <a href="{$entry->detail_url}"><h3>{$entry->company_name}</h3></a>
        </div>
        <div class="row-fluid">
          {module_action_link module='CGSocialApp' action='addcheckin' location=$entry->id text='Checkin Here'}
        </div><br />
        {if $entry->address ne ''}
          <div class="row-fluid">{$entry->address}</div>
        {/if}
        {if $entry->website ne ''}
          <div class="row-fluid"><a href="http://{$entry->website}">{$entry->website}</a></div>
        {/if}
      </div>
    </div>
_______________________________________________________________________________

    {* sample of addressing a custom field directly *}
{strip}
    {if isset($entry->fields)}
      {if isset($entry->fields.foo) && $entry->fields.foo->value != ''}
        Foo: {$entry->fields.foo->value}<br/>
      {/if}

      {* sample of addressing a field with spaces or other chars in the name
      Special Field: {assign var='tmp' value='The Field Name'}{$entry->fields.$tmp->value}<br/>
    *}
 
    {* sample of addressing the value of a dropdown field: *}
    {if isset($entry->fields.mydropdown) && $entry->fields.mydropdown->dropdown_value != ''}
      Sample Dropdown: {$entry->fields.mydropdown->dropdown_value}<br/>
    {/if}

    {* sample of looping through the fields associative array
    {foreach from=$entry->fields key='fieldname' item='field'}
      {if isset($field->value) && $field->value != ''}
        {$field->name} <em>({$field->type})</em>: {$field->value}<br/>
      {/if}
    {/foreach}
    *}
  {/if}
{/strip}

  </article>
  {foreachelse}
    <div class="alert alert-error">{$CompanyDirectory->Lang('error_nocompaniesmatch')}</div>
  {/foreach}
{/if}
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
nosyguy
Forum Members
Forum Members
Posts: 87
Joined: Tue Apr 22, 2008 8:17 pm

Re: Company Directory - alphabetical menu for sorting

Post by nosyguy »

Ah - I see it now!

Thanks so much for your help, you are appreciated.

----------
nosyguy
Post Reply

Return to “Modules/Add-Ons”