• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Please help with Smarty in CompanyDirectory template
PostPosted: Fri Aug 13, 2010 5:52 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Apr 14, 2010 5:21 pm
Posts: 83
I've just read the Smarty manual, and I still don't grasp how to accomplish what I want to do. There are no posts that I can find that handle this.

I appreciate the help I got recently from Rolf on another post where I was attempting to order the custom fields in the CompanyDirectory detail template.

(Please forgive my lack of knowledge about how to encase code in a separate box, and feel free to let me know how its done.)

I put this code at the top of the template:

Code:
{if $customfieldscount gt 0}
      {foreach from=$customfields item=customfield}
            {capture assign=$customfield->name}{$customfield->value}{/capture}
      {/foreach}
{/if}


and then displayed the Custom Fields by their name, as so:

Code:
{if $Host_Organization ne ''}
<p><strong>Host Organization:</strong> {$Host_Organization}</p>
{/if}


Works great, thanks to Rolf! I'm trying to apply the same principle to the Add/Edit a Frontend Form Template in CompanyDirectory, but if I apply it directly, there are no input boxes created in the form, nor are my values present.

I started by putting the same bit of {foreach}{capture} code at the top of the template and trying several methods of getting the custom fields to show up. Here is a sample of code from the template:

Code:
{$startform}

    <div class="row">
        <div class="prompt">{$nametext}:</div>
        <div class="input">{$inputname}</div>
    </div>

    <div class="row">
   <div class="prompt">Host Organization:</div>
   <div class="input">???</div>
    </div>


The first row is a "standard" field. The {$inputname} smarty tag is defined in action.fe_edit.php, and from my limited understanding, creates an input text field and fills in the variable if the Company ID is >0.

In the default template, the customfields are created using a tag that looks like {$customfield->input_box}, but that simply makes an empty box, and the values aren't filled in during the "Edit Company" mode.

I would like to know how to create and populate that custom field with Smarty. Anyone?

Thanks for reading this.


// Rolf : Added code tags


Last edited by kerryshamblin on Thu Mar 07, 2013 5:49 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Please help with Smarty in CompanyDirectory template
PostPosted: Fri Aug 13, 2010 6:14 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Apr 14, 2010 5:21 pm
Posts: 83
By the way, I did read this: http://calguy1000.com/Blogs/12/60/basic ... kills.html, which was a great intro.

I'm running:

CMSMS 1.8.1
CompanyDirectory 1.6.5
CGSimpleSmarty 1.4.5
CGExtensions 1.19.2
FrontEndUsers 1.12
SelfRegistration 1.6.1


Top
 Profile  
 
 Post subject: Re: Please help with Smarty in CompanyDirectory template
PostPosted: Fri Aug 13, 2010 11:07 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Apr 23, 2008 7:53 am
Posts: 6005
Location: The Netherlands
Hello Kerryshamblin,

please try this and see if it works:

Code:

{if $customfieldscount gt 0}
    {foreach from=$customfields item=customfield}
        {capture assign=$customfield->name}{$customfield->name}{/capture}
        {capture assign=foo}{$customfield->name}_input{/capture}
        {capture assign=$foo}{$customfield->input_box}{/capture}
    {/foreach}
{/if}

    <div class="row">
        <div class="prompt">{$field1}:</div>
        <div class="input">{$field1_input}</div>
    </div>
    <div class="row">
        <div class="prompt">{$Host_Organization}:</div>
        <div class="input">{$Host_Organization_input}</div>
    </div>
    <div class="row">
        <div class="prompt">{$field2}:</div>
        <div class="input">{$field2_input}</div>
    </div>



You still need to fill for field1 and field2 your names of course.

Hope this helps,

Rolf

_________________
Dutch CMSMS community website cmsms.nl and Wiki wiki.cmsms.nl
--------------------------
My CMSMS Tips and Tricks Weblog and website about Pneumatic Tube Systems / Rohrpost
My other (Dutch) website: Smakelijk eten zonder zout (Design: Compufairy)


Top
 Profile  
 
 Post subject: Re: Please help with Smarty in CompanyDirectory template
PostPosted: Fri Aug 13, 2010 11:57 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Apr 14, 2010 5:21 pm
Posts: 83
Thanks, Rolf! It works like a charm. It helps me to learn how to manipulate Smarty, too. I really appreciate it. I think it's time for my donation to CMSMS now. Cheers!


Top
 Profile  
 
 Post subject: Re: Please help with Smarty in CompanyDirectory template
PostPosted: Sat Aug 14, 2010 8:52 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Apr 23, 2008 7:53 am
Posts: 6005
Location: The Netherlands
kerryshamblin wrote:
Thanks, Rolf! It works like a charm. It helps me to learn how to manipulate Smarty, too. I really appreciate it.

Great, glad I could help.

You don't need to have the fieldname tag in the code of course.
The real names can directly in the template, like this:
Code:
{if $customfieldscount gt 0}
    {foreach from=$customfields item=customfield}
        {capture assign=foo}{$customfield->name}_input{/capture}
        {capture assign=$foo}{$customfield->input_box}{/capture}
    {/foreach}
{/if}

    <div class="row">
        <div class="prompt">Field number 1:</div>
        <div class="input">{$field1_input}</div>
    </div>
    <div class="row">
        <div class="prompt">Host Organization:</div>
        <div class="input">{$Host_Organization_input}</div>
    </div>
    <div class="row">
        <div class="prompt">Field number 2:</div>
        <div class="input">{$field2_input}</div>
    </div>



kerryshamblin wrote:
I think it's time for my donation to CMSMS now. Cheers!


Thanks!

You can also nominate CMSMS for the Packt Open Source Awards:
http://www.packtpub.com/open-source-awa ... source-cms
http://www.packtpub.com/open-source-awa ... ce-project

_________________
Dutch CMSMS community website cmsms.nl and Wiki wiki.cmsms.nl
--------------------------
My CMSMS Tips and Tricks Weblog and website about Pneumatic Tube Systems / Rohrpost
My other (Dutch) website: Smakelijk eten zonder zout (Design: Compufairy)


Top
 Profile  
 
 Post subject: Re: [SOLVED] Please help with Smarty in CompanyDirectory template
PostPosted: Sat Aug 14, 2010 9:26 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Apr 23, 2008 7:53 am
Posts: 6005
Location: The Netherlands
kerryshamblin wrote:
(Please forgive my lack of knowledge about how to encase code in a separate box, and feel free to let me know how its done.)


You can use the # button for this. It puts the code tags around the text.
I will change it for you in your first post!

Also created a Wiki page for the Company Directory module, with a link to this page.
http://wiki.cmsmadesimple.org/index.php ... yDirectory

Perhaps others might benifit from this thread.

Regards, Rolf  :)

_________________
Dutch CMSMS community website cmsms.nl and Wiki wiki.cmsms.nl
--------------------------
My CMSMS Tips and Tricks Weblog and website about Pneumatic Tube Systems / Rohrpost
My other (Dutch) website: Smakelijk eten zonder zout (Design: Compufairy)


Top
 Profile  
 
 Post subject: Re: [SOLVED] Please help with Smarty in CompanyDirectory template
PostPosted: Tue Aug 17, 2010 3:45 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Apr 14, 2010 5:21 pm
Posts: 83
Done and done! Thanks again, Rolf.


Top
 Profile  
 
 Post subject: Re: [SOLVED] Please help with Smarty in CompanyDirectory template
PostPosted: Thu Sep 30, 2010 1:57 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Apr 14, 2010 5:21 pm
Posts: 83
This was working until I changed the State_Province customfield to a dropdown instead of a text input. In the backend, I can edit the company and an actual dropdown shows up, but not in the frontend template. Is this a bug that I should report, or am I missing something?


Top
 Profile  
 
 Post subject: Re: [SOLVED] Please help with Smarty in CompanyDirectory template
PostPosted: Tue Oct 12, 2010 9:15 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Wed Aug 15, 2007 8:51 pm
Posts: 556
Location: Nairobi, Kenya
There's a slightly easier way:

{assign var=$field->name value=$field->value} with achieve the same thing without calling a capture.


Top
 Profile  
 
 Post subject: Re: [SOLVED] Please help with Smarty in CompanyDirectory tem
PostPosted: Thu Oct 20, 2011 3:58 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Apr 23, 2008 7:53 am
Posts: 6005
Location: The Netherlands
Company Directory, release 1.10+

Code:
{$entry->customfieldsbyname.yourname}
Is changed in:
Code:
{$entry->fields.yourname->value}

Hope this helps,

Rolf

_________________
Dutch CMSMS community website cmsms.nl and Wiki wiki.cmsms.nl
--------------------------
My CMSMS Tips and Tricks Weblog and website about Pneumatic Tube Systems / Rohrpost
My other (Dutch) website: Smakelijk eten zonder zout (Design: Compufairy)


Top
 Profile  
 
 Post subject: Re: [SOLVED] Please help with Smarty in CompanyDirectory tem
PostPosted: Tue Jan 29, 2013 9:44 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Apr 14, 2010 5:21 pm
Posts: 83
Thanks for posting that tip, Rolf, but I can't seem to get my add-edit-company form to generate the input boxes now that I've upgraded to 1.17. Lost Again!


Top
 Profile  
 
 Post subject: Re: Please help with Smarty in CompanyDirectory template
PostPosted: Thu Mar 07, 2013 6:24 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Apr 14, 2010 5:21 pm
Posts: 83
Hello again. I have removed the [SOLVED] from this topic because since upgrading, my add/edit company template is no longer working.

I have a list of Field Definitions that I want to intersperse in the add/edit company template with the "standard" fields, and Rolf's solution above was great until I upgraded to 1.17. Now I've upgraded to 1.17.5. It still doesn't help me figure out how to generate input boxes for custom fields in the add/edit company template.

I have the system and all relevant modules at the latest version.

Any help would make my day a little better. Thank you!


Top
 Profile  
 
 Post subject: Re: Please help with Smarty in CompanyDirectory template
PostPosted: Thu Mar 07, 2013 7:25 pm 
Offline
Administrator
Administrator
User avatar

Joined: Thu Mar 09, 2006 5:32 am
Posts: 12302
Location: Arizona
The call for the fields may have changed, add {get_template_vars} to the bottom of the template to see what the fields look like, default and custom ones...

_________________
Extensions » Modules/Tags click the name of the module/tag or Help to the right to get its parameters.
Right click and view source is a great way to see what you have to work with.
Check ver. CMSMS, PHP, server OS, in System Information page.
Default content http://multiintech.com/defaultcontent/
People are Wonderful
Business is Great
Life is Terrific
Ever wonder what happened to the Album module? Well it is alive and well.
http://album.multiintech.com/
Image


Top
 Profile  
 
 Post subject: Re: Please help with Smarty in CompanyDirectory template
PostPosted: Fri Mar 08, 2013 2:14 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Apr 14, 2010 5:21 pm
Posts: 83
Thank you, Dr. CSS. Adding that to the bottom of the add/edit company template, the default fields all showed up on that output, but the only thing that pointed toward custom fields was this:

Code:
customfields = Array (0)
customfieldscount = 0


Part of the special need is to have the field definitions interspersed with the default fields, rather than just in a clump at the end. There is nothing in the template that calls the custom fields as a group. Rolf helped out awhile back with the code I used (see above) but it stopped working after the upgrade.

I really appreciate your help.


Top
 Profile  
 
 Post subject: Re: Please help with Smarty in CompanyDirectory template
PostPosted: Wed Oct 30, 2013 11:35 pm 
Offline
Forum Members
Forum Members

Joined: Mon Nov 26, 2007 4:46 pm
Posts: 191
Did anyone find a solition for this? I'm getting the same results as kerryshamblin:

customfields = Array (0)
customfieldscount = 0

Although I have 4 created

CompanyDirectory 1.19.5
CMSMS 1.11.9


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner