[Solved] Is it possible to order Field Definitions in CompanyDirectory?
- kerryshamblin
- Forum Members
- Posts: 87
- Joined: Wed Apr 14, 2010 5:21 pm
[Solved] Is it possible to order Field Definitions in CompanyDirectory?
I've combed through the forums and the documentation, and it appears that the only available order to display CompanyDirectory Custom Fields in the templates is alphabetically.
Does anyone know how to display one custom field at a time in a template, so that Custom Fields and standard fields can be rearranged at will?
Alternatively, does someone know a way to order the Field Definitions?
Thank you.
Does anyone know how to display one custom field at a time in a template, so that Custom Fields and standard fields can be rearranged at will?
Alternatively, does someone know a way to order the Field Definitions?
Thank you.
Last edited by kerryshamblin on Wed Aug 11, 2010 6:07 pm, edited 1 time in total.
- kerryshamblin
- Forum Members
- Posts: 87
- Joined: Wed Apr 14, 2010 5:21 pm
Re: Is it possible to order Field Definitions in CompanyDirectory?
So, I'll add all the details of the system I'm working on, in hopes that someone who can will guide me toward a solution. I thought I was asking a general question, but maybe knowing all of this will inspire someone to reply.
CMS Version 1.8.1
CGExtensions 1.19.2
CGSimpleSmarty 1.4.5
CompanyDirectory 1.6.5
CustomContent 1.7.3
FrontEndUsers 1.12
I'm feverishly trying to learn about Smarty variables, as I suspect that I could do what I want to do if I knew how to work Smarty.
It seems there are "standard" fields that Company Directory collects, namely: address, contact_email, telephone, fax, details and website. Other "Custom Fields" can be created as Field Definitions and I see that those custom fields can be displayed in the template like this:
{if $customfieldscount gt 0}
{foreach from=$customfields item=customfield}
{$customfield->name}: {$customfield->value}
{/foreach}
{/if}
However, I'm not happy with the order of display of these custom fields. I can see in the database that each of these custom fields has an id and an item_order. I would like to either be able to order the customfields in the output, or better yet display each custom field where I want it in the template, interspersed with the "standard" fields in the form that the user sees.
I've literally spent days searching the forum for topics related to this, and I'm only posting because I haven't found anything. Any help or guidance would be greatly appreciated.
CMS Version 1.8.1
CGExtensions 1.19.2
CGSimpleSmarty 1.4.5
CompanyDirectory 1.6.5
CustomContent 1.7.3
FrontEndUsers 1.12
I'm feverishly trying to learn about Smarty variables, as I suspect that I could do what I want to do if I knew how to work Smarty.
It seems there are "standard" fields that Company Directory collects, namely: address, contact_email, telephone, fax, details and website. Other "Custom Fields" can be created as Field Definitions and I see that those custom fields can be displayed in the template like this:
{if $customfieldscount gt 0}
{foreach from=$customfields item=customfield}
{$customfield->name}: {$customfield->value}
{/foreach}
{/if}
However, I'm not happy with the order of display of these custom fields. I can see in the database that each of these custom fields has an id and an item_order. I would like to either be able to order the customfields in the output, or better yet display each custom field where I want it in the template, interspersed with the "standard" fields in the form that the user sees.
I've literally spent days searching the forum for topics related to this, and I'm only posting because I haven't found anything. Any help or guidance would be greatly appreciated.
Re: Is it possible to order Field Definitions in CompanyDirectory?
Hey,
You can try using this in the top of your detail template:
This way you assign the fieldcontent to a string, in stead of displaying it
You can use for instance {$your_field_name} in your detail template on any place you want.
Hope this helps
Rolf :)
You can try using this in the top of your detail template:
Code: Select all
{if $customfieldscount gt 0}
{foreach from=$customfields item=customfield}
{capture assign=$customfield->name}{$customfield->value}{/capture}
{/foreach}
{/if}
You can use for instance {$your_field_name} in your detail template on any place you want.
Hope this helps
Rolf :)
Last edited by Rolf on Wed Aug 11, 2010 5:28 pm, edited 1 time in total.
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
- kerryshamblin
- Forum Members
- Posts: 87
- Joined: Wed Apr 14, 2010 5:21 pm
Re: Is it possible to order Field Definitions in CompanyDirectory?
Thanks, Rolf.
I understand the theory of what you are suggesting, but I'm having trouble implementing. I've inserted the code you provided at the top of the detail template, but I'm having trouble with displaying the desired customfield->value in the template.
The Field Definitions in my CompanyDirectory have names like Host Organization and Academic Director. So, I'm trying to display the values of those fields using your suggestion and placing {$'Host Organization'} doesn't work nor does {$Host Organization}, and I've tried an array of other silly, stabbing-in-the-dark attempts.
Please forgive my lack of prowess in this department, and thank you so much for helping. If you could coddle me along any further, I would be grateful.
I understand the theory of what you are suggesting, but I'm having trouble implementing. I've inserted the code you provided at the top of the detail template, but I'm having trouble with displaying the desired customfield->value in the template.
The Field Definitions in my CompanyDirectory have names like Host Organization and Academic Director. So, I'm trying to display the values of those fields using your suggestion and placing {$'Host Organization'} doesn't work nor does {$Host Organization}, and I've tried an array of other silly, stabbing-in-the-dark attempts.
Please forgive my lack of prowess in this department, and thank you so much for helping. If you could coddle me along any further, I would be grateful.
Re: Is it possible to order Field Definitions in CompanyDirectory?
Some additional information:
Create field definitions with names like name or some_name. No spaces! Use underscore instead.
In the template you can use these parameters as:
Hopes this made it more clear ;)
Regards, Rolf
ps.
In your case something like:
And host_organization is here the name of the field definition.
Create field definitions with names like name or some_name. No spaces! Use underscore instead.
In the template you can use these parameters as:
Code: Select all
<p>The name is {$name}</p>
Code: Select all
{if $name}
<p>The name is {$name}</p>
{/if}
Code: Select all
{if $some_name}
<p>Search with Google for: <a href="http://www.google.com/search?q={$some_name}">{$some_name}</a></p>
{/if}
Regards, Rolf
ps.
In your case something like:
Code: Select all
<p>Name Host Organization: {$host_organization}</p>
And host_organization is here the name of the field definition.
Last edited by Rolf on Wed Aug 11, 2010 5:34 pm, edited 1 time in total.
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
- kerryshamblin
- Forum Members
- Posts: 87
- Joined: Wed Apr 14, 2010 5:21 pm
Re: Is it possible to order Field Definitions in CompanyDirectory?
Thanks, Rolf! Problem solved. Now on to the other problems... 

- kerryshamblin
- Forum Members
- Posts: 87
- Joined: Wed Apr 14, 2010 5:21 pm
Re: [Solved] Is it possible to order Field Definitions in CompanyDirectory?
I'm now trying to apply this theory to the Summary Template. The code I'm working with looks like this:
As you can see, I inserted the same code Rolf suggested at the top of the template, and then called the custom fields by name, but they aren't showing up in the Summary. Any ideas?
Code: Select all
{if $customfieldscount gt 0}
{foreach from=$customfields item=customfield}
{capture assign=$customfield->name}{$customfield->value}{/capture}
{/foreach}
{/if}
{if isset($items)}
{foreach from=$items item=entry}
<div class="CompanyDirectoryItem">
<strong>{$entry->company_name}</strong><br />
{$City}, {$State}<br />
<a href="{$entry->detail_url}">Details</a>
{if $entry->website ne ''}
– <a href="{$entry->website}">Web Site</a>
{/if}
</div>
{/foreach}
Re: [Solved] Is it possible to order Field Definitions in CompanyDirectory?
Uhm, I am not shure these fields are available in the summary view...kerryshamblin wrote: I'm now trying to apply this theory to the Summary Template.
...but they aren't showing up in the Summary. Any ideas?

Thought I read a reply of Calguy somewhere that this wasn't the case.
grtz. Rolf
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Re: [Solved] Is it possible to order Field Definitions in CompanyDirectory?
Hi kerryshamblin,
Searching for the post of Calguy I mentioned, which might not even excist
I found another, much better solution...!
You can use this in both the summary, as detail templates.
Grtz. Rolf
Searching for the post of Calguy I mentioned, which might not even excist

Code: Select all
{$entry->customfieldsbyname.yourfieldname}
Grtz. Rolf
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
- kerryshamblin
- Forum Members
- Posts: 87
- Joined: Wed Apr 14, 2010 5:21 pm
Re: [Solved] Is it possible to order Field Definitions in CompanyDirectory?
What an excellent solution! So simple. Thank you so much.
Re: [Solved] Is it possible to order Field Definitions in CompanyDirectory?
Just want to thank you both. This post saved me SO much time and headache. Sending kudos and happiness your way on this lovely Friday afternoon. Enjoy your day!
Mmmmm... Tasty.
Re: [Solved] Is it possible to order Field Definitions in CompanyDirectory?
Good to hearjtcreate wrote: Just want to thank you both. This post saved me SO much time and headache. Sending kudos and happiness your way on this lovely Friday afternoon. Enjoy your day!

I also created a new wiki page on this:
http://wiki.cmsmadesimple.org/index.php ... yDirectory
®
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Re: [Solved] Is it possible to order Field Definitions in Co
I found your info on these pages most helpful. I am however a bit stuck. i am not a genius at coding to please please bear with me.
I have created a number of checkboxes under the Flied Definitions. I only want the checked boxes to show up. For some reason all of the Field Definitions are showing up once you call up the detail of a company on the front end.
Am I just daft?
I have created a number of checkboxes under the Flied Definitions. I only want the checked boxes to show up. For some reason all of the Field Definitions are showing up once you call up the detail of a company on the front end.
Am I just daft?
Re: [Solved] Is it possible to order Field Definitions in Co
No, you are not
In the details template there is are a couple lines that call all customfields, search for:
If you don't want all these custom checkboxes you'll have to call them all individually:
Where 'Yourname' is the exact name you specified for you checkbox (Case-sensitive)
What you can also do, is to check if there is a value for a certain box and display it if answer is yes:

In the details template there is are a couple lines that call all customfields, search for:
Code: Select all
{if $customfieldscount gt 0}
{foreach from=$customfields item=customfield}
{$customfield->name}: {$customfield->value}<br />
{/foreach}
{/if}
Code: Select all
{$entry->customfieldsbyname.Yourname}
What you can also do, is to check if there is a value for a certain box and display it if answer is yes:
Code: Select all
{if $entry->customfieldsbyname.Yourname ne ''}
{$entry->customfieldsbyname.Yourname}
{/if}
Make your community a better place!
Re: [Solved] Is it possible to order Field Definitions in Co
thank you so incredibly much M@rtijn!!!