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
[SOLVED] Company Directory - alphabetical menu for sorting
[SOLVED] Company Directory - alphabetical menu for sorting
Last edited by nosyguy on Fri Jan 10, 2014 6:28 pm, edited 1 time in total.
Re: Company Directory - alphabetical menu for sorting
I have made that once. Have to look it up tomorrow...
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Re: Company Directory - alphabetical menu for sorting
That would be fantastic - thanks!
----------
nosyguy
----------
nosyguy
Re: Company Directory - alphabetical menu for sorting
http://www.zeijen.nu/bedrijven
Code: Select all
{assign var=initial value=null}
<p>Directly to first letter:
{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>
{/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
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Re: Company Directory - alphabetical menu for sorting
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. 
Re: Company Directory - alphabetical menu for sorting
Oh.. It was CGUserDirectory that had this feature.
Re: Company Directory - alphabetical menu for sorting
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:
You can see the page testing at this link:
http://198.104.112.247/~nosyguy9/trista ... -directory
------------
nosyguy
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:
{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>
{/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} {$prevlink} {/if}
{$pagetext} {$curpage} {$oftext} {$pagecount}
{if isset($nextlink)} {$nextlink} {$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}
http://198.104.112.247/~nosyguy9/trista ... -directory
------------
nosyguy
Re: Company Directory - alphabetical menu for sorting
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:
{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>
{/if}
{/foreach}
</p>
{if isset($items)}
{if isset($firstlink) || isset($nextlink)}
<div>
{if isset($firstlink)}{$firstlink} {$prevlink} {/if}
{$pagetext} {$curpage} {$oftext} {$pagecount}
{if isset($nextlink)} {$nextlink} {$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
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Re: Company Directory - alphabetical menu for sorting
Ah - I see it now!
Thanks so much for your help, you are appreciated.
----------
nosyguy
Thanks so much for your help, you are appreciated.
----------
nosyguy


