Page 1 of 1

Add a standard field to CompanyDirectory

Posted: Thu Jan 24, 2008 9:38 am
by Droax
Because custom fields are placed in a different table and can't be displayed in de companylist, I want to put a extra standard field ('city') to the module CompanyDirectory. I have put new lines under '#Display template' in the file action.addcompany.php :

Code: Select all

$this->smarty->assign('citytext', $this->Lang('city'));
$this->smarty->assign('inputcity', $this->CreateInputText($id, 'city', $city, 30, 255));
And in the template 'editcompany.tpl', i have add:

Code: Select all

<div class="pageoverflow">
  <p class="pagetext">{$citytext}:</p>
  <p class="pageinput">{$inputcity}</p>
</div>
After this action, the least i can espect is an extra field in the form 'add new company', but i get a extra field with the following label:

--Add Me - module:CompanyDirectory string:city--:

This should be ' city ' without the stuff before it :-\

What is the reason for the extra code? Or better, how can i put a extra standaard field to Company Directory without using custom fields?

When i make a copy of the addressfield in the template, i will display double with the same and normal label. So, i don't see any problems in the way i use the template.

Re: Add a standard field to CompanyDirectory

Posted: Thu Jan 24, 2008 9:31 pm
by alastair
After this action, the least i can espect is an extra field in the form 'add new company', but i get a extra field with the following label:

--Add Me - module:CompanyDirectory string:city--:

This should be ' city ' without the stuff before it Undecided

What is the reason for the extra code? Or better, how can i put a extra standaard field to Company Directory without using custom fields?
You need to add city to your language file - en_US.php for English, which is located in the lang sub directory.  If you add
$lang['city'] = 'City';
$lang['citytext'] = 'City';
you will get the correct string

Happy hacking!

Re: Add a standard field to CompanyDirectory

Posted: Fri Apr 11, 2008 1:46 am
by JonV
Just wanted to post as i just figured out how to successfully do all this. I edited quite a few more files than is posted above, as i wanted my variables to be searchable.

Here is a list of files i edited:
CompanyDirectory.module.php
action.fe_edit.php
action.exportcsv.php
action.editcompany.php
action.details.php
action.defaultadmin.php
action.default.php
action.addcompany.php - add extra ? for extra variable
en_US.php
orig_frontendform_template.tpl
orig_detail_template.tpl
editcompany.tpl


I basically just followed the format of the existing variables in the files, however one threw me off and i missed it during editing and wanted to point it out specifically.

When editing action.addcompany.php, there is a place about line 167 where it takes your variables and puts them into an array.

Code: Select all

$query = 'INSERT INTO '.cms_db_prefix().'module_compdir_companies (company_name, address, telephone, cell, fax, contact_email, website, team, title, reports_to, responsible_areas, details, picture_location, logo_location, create_date, modified_date, status) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
		$db->Execute($query, array($company_name, $address, $telephone, $cell, $fax, $contact_email, $website, $team, $title, $reports_to, $responsible_areas, $details, $image, $logo, trim($db->DBTimeStamp(time()), "'"), trim($db->DBTimeStamp(time()), "'"), $status));

The section VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'; needs to have the same number of ?'s as variables to pass the information into the array to be written to your tables.

If you don't, you will find yourself unable to add new entry's to the database, but you are able to edit them fine. I missed it and it caused a minor headache, so i wanted to point it out.

Re: Add a standard field to CompanyDirectory

Posted: Fri May 02, 2008 11:48 pm
by pixelita
Would be nice if instead of just "address" the Company Directory had these fields:

City
State or Province
ZIP or Postal Code

I have added these under "Fields" and tried to add them to the templates, and they show up if you are filling out the form, but I cannot get them to display on the summary or detail templates to save my neck.

Re: Add a standard field to CompanyDirectory

Posted: Wed Nov 04, 2009 1:25 am
by Frankie
i finally got it to display the values of the custom fields by using:

Code: Select all

{$entry->customfields[1]->value}
where [1] is the ID of the custom field...to find the ID simply open up a Field Definition like you're going to edit it and the ID Number is at the end of the URL in your browser (fdid=ID_NUMBER)

as long as you have it within a foreach statement it works like a charm! good luck.

Re: Add a standard field to CompanyDirectory

Posted: Sun Feb 28, 2010 10:06 am
by brandy
I have made a new field in Company Directory - now I want to insert it to my template - I added the following lines in the foreach-section, where the other fields are, but it don´t show up.

Code: Select all

{if $entry->customsfield[4] ne ''}
Telefon: {$entry->customsfield[4]->value}<br />
{/if}
What do I have to do?

Thanks for your answers?

Re: Add a standard field to CompanyDirectory

Posted: Sun Feb 28, 2010 8:18 pm
by jmcgin51
try like this

{$entry->customfieldsbyname.yourcustomfieldname}

Re: Add a standard field to CompanyDirectory

Posted: Mon Mar 01, 2010 2:39 pm
by athena_pallas
Hello,
I just tried it in my summary template and it's working :

Code: Select all

{if isset($items)}
 <ul>
  {foreach from=$items item=entry}
  <div class="CompanyDirectoryItem">
     <li>  <a href="{$entry->detail_url}">{$entry->company_name}</a>
<i>{$entry->customfieldsbyname.fr_specialite}</i>
</li>
  </div>
  {/foreach}
</ul>
{/if}
Thanks !
Have a nice day.

Re: Add a standard field to CompanyDirectory

Posted: Mon Mar 08, 2010 5:31 pm
by brandy
Okay I found the problem - You have to set the status to public to see the field!

Thanks for your help!