Page 1 of 2

Company Directory module - display content of custom fields

Posted: Thu Jan 04, 2007 10:10 pm
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

Re: Company Directory module - display content of custom fields

Posted: Thu Jan 04, 2007 10:28 pm
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

Re: Company Directory module - display content of custom fields

Posted: Thu Jan 04, 2007 11:22 pm
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]

Re: Company Directory module - display content of custom fields

Posted: Fri Jan 05, 2007 1:45 am
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

Re: Company Directory module - display content of custom fields

Posted: Fri Jan 05, 2007 2:01 am
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

Re: Company Directory module - display content of custom fields

Posted: Fri Jan 05, 2007 2:27 am
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}

Re: Company Directory module - display content of custom fields

Posted: Fri Jan 05, 2007 3:02 am
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]

Re: Company Directory module - display content of custom fields

Posted: Fri Jan 05, 2007 3:13 am
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

Re: Company Directory module - display content of custom fields

Posted: Fri Jan 05, 2007 7:12 pm
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

Re: Company Directory module - display content of custom fields

Posted: Wed Jan 17, 2007 4:06 am
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

Re: Company Directory module - display content of custom fields

Posted: Wed Jan 17, 2007 4:44 am
by Ted
{cms_module module='companydirectory'} is all you should need to display it on the frontend.

Ted

Re: Company Directory module - display content of custom fields

Posted: Wed Jan 17, 2007 1:53 pm
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

Re: Company Directory module - display content of custom fields

Posted: Wed Jan 17, 2007 2:06 pm
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

Re: Company Directory module - display content of custom fields

Posted: Wed Jan 17, 2007 2:40 pm
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.  :)

Re: Company Directory module - display content of custom fields

Posted: Wed Jan 17, 2007 3:01 pm
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