[Solved] Is it possible to order Field Definitions in CompanyDirectory?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
User avatar
kerryshamblin
Forum Members
Forum Members
Posts: 87
Joined: Wed Apr 14, 2010 5:21 pm

[Solved] Is it possible to order Field Definitions in CompanyDirectory?

Post by kerryshamblin »

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.
Last edited by kerryshamblin on Wed Aug 11, 2010 6:07 pm, edited 1 time in total.
User avatar
kerryshamblin
Forum Members
Forum Members
Posts: 87
Joined: Wed Apr 14, 2010 5:21 pm

Re: Is it possible to order Field Definitions in CompanyDirectory?

Post by kerryshamblin »

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.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Is it possible to order Field Definitions in CompanyDirectory?

Post by Rolf »

Hey,

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}
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  :)
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
- + - + - + - + - + - + -
Image
User avatar
kerryshamblin
Forum Members
Forum Members
Posts: 87
Joined: Wed Apr 14, 2010 5:21 pm

Re: Is it possible to order Field Definitions in CompanyDirectory?

Post by kerryshamblin »

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.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Is it possible to order Field Definitions in CompanyDirectory?

Post by Rolf »

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:

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}
Hopes this made it more clear  ;)

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
- + - + - + - + - + - + -
Image
User avatar
kerryshamblin
Forum Members
Forum Members
Posts: 87
Joined: Wed Apr 14, 2010 5:21 pm

Re: Is it possible to order Field Definitions in CompanyDirectory?

Post by kerryshamblin »

Thanks, Rolf! Problem solved. Now on to the other problems...  ;)
User avatar
kerryshamblin
Forum Members
Forum Members
Posts: 87
Joined: Wed Apr 14, 2010 5:21 pm

Re: [Solved] Is it possible to order Field Definitions in CompanyDirectory?

Post by kerryshamblin »

I'm now trying to apply this theory to the Summary Template. The code I'm working with looks like this:

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}
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?
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: [Solved] Is it possible to order Field Definitions in CompanyDirectory?

Post by Rolf »

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?
Uhm, I am not shure these fields are available in the summary view...  :-\
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
- + - + - + - + - + - + -
Image
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: [Solved] Is it possible to order Field Definitions in CompanyDirectory?

Post by Rolf »

Hi kerryshamblin,

Searching for the post of Calguy I mentioned, which might not even excist ;) I found another, much better solution...!

Code: Select all

{$entry->customfieldsbyname.yourfieldname}
You can use this in both the summary, as detail templates.

Grtz. Rolf
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
kerryshamblin
Forum Members
Forum Members
Posts: 87
Joined: Wed Apr 14, 2010 5:21 pm

Re: [Solved] Is it possible to order Field Definitions in CompanyDirectory?

Post by kerryshamblin »

What an excellent solution! So simple. Thank you so much.
User avatar
jtcreate
Forum Members
Forum Members
Posts: 168
Joined: Wed Mar 21, 2007 11:01 am

Re: [Solved] Is it possible to order Field Definitions in CompanyDirectory?

Post by jtcreate »

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.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: [Solved] Is it possible to order Field Definitions in CompanyDirectory?

Post by Rolf »

jtcreate 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!
Good to hear  :)

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
- + - + - + - + - + - + -
Image
ACDS
Forum Members
Forum Members
Posts: 17
Joined: Tue Jul 12, 2011 12:02 pm

Re: [Solved] Is it possible to order Field Definitions in Co

Post by ACDS »

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?
User avatar
M@rtijn
Power Poster
Power Poster
Posts: 706
Joined: Sat Nov 14, 2009 4:54 pm

Re: [Solved] Is it possible to order Field Definitions in Co

Post by M@rtijn »

No, you are not ;D

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}
If you don't want all these custom checkboxes you'll have to call them all individually:

Code: Select all

{$entry->customfieldsbyname.Yourname}
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:

Code: Select all

{if $entry->customfieldsbyname.Yourname ne ''}
{$entry->customfieldsbyname.Yourname}
{/if}
Make your community a better place!
ACDS
Forum Members
Forum Members
Posts: 17
Joined: Tue Jul 12, 2011 12:02 pm

Re: [Solved] Is it possible to order Field Definitions in Co

Post by ACDS »

thank you so incredibly much M@rtijn!!!
Post Reply

Return to “Modules/Add-Ons”