Add a standard field to CompanyDirectory

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Droax
New Member
New Member
Posts: 8
Joined: Wed Nov 07, 2007 12:48 pm

Add a standard field to CompanyDirectory

Post 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.
Last edited by Droax on Thu Jan 24, 2008 9:47 am, edited 1 time in total.
alastair

Re: Add a standard field to CompanyDirectory

Post 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!
JonV
New Member
New Member
Posts: 4
Joined: Fri Apr 11, 2008 1:36 am

Re: Add a standard field to CompanyDirectory

Post 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.
Last edited by JonV on Fri Apr 11, 2008 1:55 am, edited 1 time in total.
User avatar
pixelita
Power Poster
Power Poster
Posts: 388
Joined: Sun Sep 16, 2007 3:07 am
Location: Houston, Texas USA

Re: Add a standard field to CompanyDirectory

Post 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.
Submit your site to the We Love CMSMS showcase
Frankie

Re: Add a standard field to CompanyDirectory

Post 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.
brandy
Forum Members
Forum Members
Posts: 146
Joined: Mon Apr 21, 2008 5:32 pm

Re: Add a standard field to CompanyDirectory

Post 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?
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Add a standard field to CompanyDirectory

Post by jmcgin51 »

try like this

{$entry->customfieldsbyname.yourcustomfieldname}
athena_pallas
Power Poster
Power Poster
Posts: 272
Joined: Wed Sep 13, 2006 4:41 pm
Location: Belgium

Re: Add a standard field to CompanyDirectory

Post 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.
brandy
Forum Members
Forum Members
Posts: 146
Joined: Mon Apr 21, 2008 5:32 pm

Re: Add a standard field to CompanyDirectory

Post by brandy »

Okay I found the problem - You have to set the status to public to see the field!

Thanks for your help!
Post Reply

Return to “Modules/Add-Ons”