Company Directory module - display content of custom fields

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
skypanther

Company Directory module - display content of custom fields

Post by skypanther »

Has anyone figured out how to display the contents of specific custom fields with the company directory module? Help and documentation for the module is non-existant. From the sample templates, I can see how to output all of the custom fields. But, I want to modify the summary template to output the contents of just one of my custom fields.

Thanks in advance,
Tim
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm
Location: the Netherlands

Re: Company Directory module - display content of custom fields

Post by Dee »

Hmm, as far as I can see from examining the code the custom fields are not assigned to smarty/the template...

Regards,
D
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm
Location: the Netherlands

Re: Company Directory module - display content of custom fields

Post by Dee »

They are not assigned in the summary view, but when you view company details the custom fields are assigned.
This is the code in the detail template that shows them:

Code: Select all

{if $customfieldscount gt 0}
	{foreach from=$customfields item=customfield}
		{$customfield->name}: {$customfield->value}<br />
	{/foreach}
{/if}
Use the attached action.default.php to also assign the custom fields to the summary. Use this code in the Summary Template to show them:

Code: Select all

{if $entry->customfieldscount gt 0}
	{foreach from=$entry->customfields item=customfield}
		{$customfield->name}: {$customfield->value}<br />
	{/foreach}
{/if}
Regards,
D

[gelöscht durch Administrator]
Last edited by Anonymous on Fri Jan 05, 2007 12:50 am, edited 1 time in total.
skypanther

Re: Company Directory module - display content of custom fields

Post by skypanther »

Thanks Dee. How can I show the contents of just one of the custom fields though? Let's say I add a custom field called Slogan and I want to display the company's name, web site and slogan on my summary page...it would be great if I could do something like this:

Code: Select all

Name: {$entry->company_name_link}<br />

{if $entry->website ne ''}
   Website: <a href="{$entry->website}">{$entry->website}</a><br />
{/if}

{if $customfields->slogan ne ''}
   Slogan: {$customfields->slogan}<br />
{/if}
I'd even deal with {$customfields[0]} where the number is the custom field's number in the compdir_fielddefs table.

Tim
skypanther

Re: Company Directory module - display content of custom fields

Post by skypanther »

I figured it out! With your patch applied, I can output the value of a custom field using:

{$entry->customfields[1]->value}

Where the number is the custom field's number, using cardinal numbering (i.e. the first custom field is 1 not 0).

Any idea how I can output a list of the categories (as links) rather than the drop-down list form element?

Tim
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm
Location: the Netherlands

Re: Company Directory module - display content of custom fields

Post by Dee »

You could also use

Code: Select all

{if $entry->customfieldscount gt 0}
	{foreach from=$entry->customfields item=customfield}
		{if $customfield->name == 'slogan' and $customfield->value ne ''}
			{$customfield->name}: {$customfield->value}<br />
		{/if}
	{/foreach}
{/if}
Last edited by Anonymous on Fri Jan 05, 2007 3:03 am, edited 1 time in total.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm
Location: the Netherlands

Re: Company Directory module - display content of custom fields

Post by Dee »

skypanther wrote: Any idea how I can output a list of the categories (as links) rather than the drop-down list form element?
In action.default.php at the start after

Code: Select all

if (isset($_POST[$id.'inputcat']))
{
	$inputcat = $_POST[$id.'inputcat'];
}
add

Code: Select all

if (isset($params['inputcat']))
{
	$inputcat = $params['inputcat'];
}
and, at the end of the file, change

Code: Select all

$catarray = array('(Select One)' => '');

while ($dbresult && $row = $dbresult->FetchRow())
{
	$catarray[$row['name']] = $row['id'];
}

$this->smarty->assign('catformstart', $this->CreateFrontendFormStart($id, $returnid));
$this->smarty->assign('catdropdown', $this->CreateInputDropdown($id, 'inputcat', $catarray, -1, $inputcat, ''));
$this->smarty->assign('catbutton', $this->CreateInputSubmit($id, 'inputsubmit', 'Submit'));
$this->smarty->assign('catformend', $this->CreateFormEnd());
to

Code: Select all

$html = '';
while ($dbresult && $row = $dbresult->FetchRow())
{
	$html .= $this->CreateLink($id, 'default', $returnid, $row['name'], array('inputcat' => $row['id']));
	$html .= '<br />';
}
$this->smarty->assign('catformstart', $html);
Regards,
D

[gelöscht durch Administrator]
skypanther

Re: Company Directory module - display content of custom fields

Post by skypanther »

Many thanks! It outputs the category list just fine. Ultimately, what I'd like is a list of categories on one page that then links to another page listing the companies w/in that category. I'll play with this code and give a go at making that sort of modification.

Thanks so much,
Tim
climberusa
Forum Members
Forum Members
Posts: 126
Joined: Sun Feb 26, 2006 7:10 pm

Re: Company Directory module - display content of custom fields

Post by climberusa »

Dee, this all helped me out tons. I have a few questions if you have the time.

1. For my purposes it would be absolutely ideal if when you clicked on the link for a detailed view of a company it was done in a pop-up. Is there anyway to add attributes to the anchor that is created like class="external" or something?

2. I'm using the category view you created instead of the drop down list. When I click on a category I lose the list of cateogories. Is there a way to keep that on the template all the time?

3. How about adding a contextual back link or something so you don't have to use the back button each time?

I'd love to be able to add this functionality. I appreciate your help.

Jeff
bex

Re: Company Directory module - display content of custom fields

Post by bex »

I have a very basic question.

Once I install Company Directory, what do I add to my template to get it onto my site?  Or how do I create a directory page?

thanks,

bex
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: Company Directory module - display content of custom fields

Post by Ted »

{cms_module module='companydirectory'} is all you should need to display it on the frontend.

Ted
bex

Re: Company Directory module - display content of custom fields

Post by bex »

Thank you, that worked perfectly.

So I can learn from my ways - where did you find this documented (directly or indirectly)?

thanks,

bex
skypanther

Re: Company Directory module - display content of custom fields

Post by skypanther »

bex,

{cms_module module='module_name'}

is the standard way to output the results of any module in CMS-MS. Most modules should tell you what to put in the module="" parameter. From the Extensions menu, choose Modules. Next to the module in question, click Help. The help docs should include the module name and other pertinent info. In this case, the company directory module is essentially undocumented.

Tim

PS: This is also a little hint to modules developers to always include such info!  ;D
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: Company Directory module - display content of custom fields

Post by Ted »

Plus, I wrote the thing.  :)

It was written for a client who knew how it worked and what the requirements are.  I never got around to writing the help function since he didn't really need it.  And then I just released it as GPL without really thinking twice about it.  I'll get around to it eventually.  :)
skypanther

Re: Company Directory module - display content of custom fields

Post by skypanther »

Ted,

I have a need to add functionality to this module. I've been tinkering with it for a week or so and hope to have something to share within the next week or so. I can add some rudimentary documentation at that point. Perhaps that will suffice or maybe you can round it out at that point.

Tim
Locked

Return to “Modules/Add-Ons”