Company Directory and Smarty tags (module calls) [SOLVED]

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Company Directory and Smarty tags (module calls) [SOLVED]

Post by jmcgin51 »

Using CMSMS 1.6 and Company Directory 1.1.7, I am trying to include a Smarty module call (specifically for Uploads), in the Details editor.

For each company, there are certain files that should be available for download, so I want to include the appropriate Uploads reference.

For example:
Thanks for taking the time to read about our company.  Below is our latest annual report, along with biographies of our board members.

{cms_module module="Uploads" category="ourcompany" mode="summary"}
The problem is that the Smarty tag doesn't get processed; it's just spit out as text.  So rather than getting the overview text and then a list of files to download, I get exactly what you see quoted above.

Can Company Directory not process Smarty tags?

Thanks!
Last edited by jmcgin51 on Wed Jul 08, 2009 3:29 am, edited 1 time in total.
JeremyBASS

Re: Company Directory and Smarty tags (module calls)

Post by JeremyBASS »

This may be a simple but unwanted fix ... why not

{cms_module module="CompanyDirectory" }
{cms_module module="Uploads" category="ourcompany" mode="summary"}

?? Just a thought...

Cheers
Jeremy
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Company Directory and Smarty tags (module calls)

Post by jmcgin51 »

Thanks Jeremy - I see I need to provide more details.  I have CompanyDirectory set up with say 5 companies.  I use {cms_module module='CompanyDirectory'} to call the module on a page.  That all works fine, and produces a listing of the 5 companies, according to the template I selected.

NOW, I want to click on one of those companies to view more details, per the detail template.  The detail template shows the extra company information, including the stuff from the Details box, where I have placed the stuff specified in my original post.

Thinking about it again, I suppose I could try putting the Uploads call in my detail template.  I just have to figure out how to make it call the correct files based on the company that is being displayed...

Something like:
{capture assign="companyname"}
what would go in here?  have to figure this one out
{/capture}

{if $companyname='foo'}
{cms_module module="Uploads" category="foo_files" mode="summary"}
{elseif $companyname='bar'}
{cms_module module="Uploads" category="bar_files" mode="summary"}
{/if}

The way I was trying to do it original is much more flexible, though (I think).

Calguy - can you say for sure if Company Directory processes Smarty tags in the Details box?  Thanks!
Last edited by jmcgin51 on Wed Jul 01, 2009 10:56 pm, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Company Directory and Smarty tags (module calls)

Post by calguy1000 »

reading the smarty manual will help.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
JeremyBASS

Re: Company Directory and Smarty tags (module calls)

Post by JeremyBASS »

Well if you may be able to do this..

{assign var=$foo value=$foo}

and then call the foo company like this

{cms_module module="Uploads" category="`$foo`_files" mode="summary"}

that way there is less if else stuff going on and no capture either... I do that for a FEU-Userdirectory-Uploads setup... which is listing companies... I found that is more flexable and gives me tons of extar power as I can do things like


{assign var=userids value=$gCms->modules.FrontEndUsers.object->LoggedinId()}
{assign var=username value=$gCms->modules.FrontEndUsers.object->GetUserName($userids)}

which stops the need for custom content mod... and what not... this is how I do the same thing your wanting to do... :) hope that helps

Cheers
Jeremy
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Company Directory and Smarty tags (module calls)

Post by jmcgin51 »

cool - thanks a lot guys!

I'll see what I can come up with...

@calguy - I'm not 100% sure I follow.  I know the Smarty manual will help with the syntax, etc., but it's not going to tell me if Company Directory will process Smarty tags.  This is specific to the module, right?  I assumed I could use a tag in any mod (News, Company Directory, FEU user profiles, etc.), but maybe that's not correct?
Last edited by jmcgin51 on Wed Jul 01, 2009 11:11 pm, edited 1 time in total.
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Company Directory and Smarty tags (module calls)

Post by jmcgin51 »

ok, I'm feeling particularly dumb.  It doesn't appear that Company Directory will interpret any Smarty tag placed in the Details editor.  I tried {sitename}, {current_date}, as well as the module calls mentioned above, all with no luck.  What am I missing?
JeremyBASS

Re: Company Directory and Smarty tags (module calls)

Post by JeremyBASS »

jmcgin51 sorry I don't use it so I wouldn't know... but this IIRC is true.. you can tie googlemap mod to it... so I'd think you can.. but again I don't do this setup .. I use the route FEU-Userdirectory-Uploads ... have you tried {get_template_vars}??

Sorry I couldn't help more...
Cheers
Jeremy
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Company Directory and Smarty tags (module calls)

Post by jmcgin51 »

thanks, Jeremy.  Placing {get_template_vars} in the CompanyDirectory Details editor doesn't help.  It just prints {get_template_vars} on the page (not the actual variables).

Placing the {get_template_vars} in the page template works fine, but doesn't give me any clues.
JeremyBASS

Re: Company Directory and Smarty tags (module calls)

Post by JeremyBASS »

jmcgin51 that was just a final test in my eyes... so you may try this...

{capture}{cms_module module="CompanyDirectory" }{/capture}
put the template below on the page and now you should be able to inject what your wanting...

else ... well that should work... Note I don't know the call for CompanyDirectory but you do... :D

Hope that helps...

Jeremy
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Company Directory and Smarty tags (module calls)

Post by jmcgin51 »

Still haven't resolved the original question here, which was "is there a problem with CompanyDirectory processing Smarty tags in the Details field?", but I worked around it and came up with what I think will be a good solution.  Here's the code, for reference:

(I created a custom text field called "Uploads_Directory", where the company editor or admin can place the comma-separated category names from the Uploads module.  Then put this code in the template:

{*if the custom field count is greater than 0, and the custom field name is Uploads_Category, and the custom field value is not empty, then take the value and use it as the category name to display Uploads.  Users need to enter a comma-separated list of Uploads categories in the Uploads_Category field (no spaces, just commas).  If no categories are entered, the code below is ignored.*}
{if $customfieldscount gt 0}
  {foreach from=$customfields item=customfield}
    {if $customfield->name eq "Uploads_Category" && $customfield->value ne ''}
     
        {capture assign="customfieldarray"}{$customfield->value}{/capture}
          {assign var="array" value=$customfieldarray}
            {assign var="testsplit" value=","|explode:$array}
              {foreach from=$testsplit item=field}
                {cms_module module="Uploads" category=$field mode="summary"}


                {/foreach}
       
    {/if}
  {/foreach}
{/if}
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Company Directory and Smarty tags (module calls) [WORKED-AROUND]

Post by calguy1000 »

The problem is that the Smarty tag doesn't get processed; it's just spit out as text.  So rather than getting the overview text and then a list of files to download, I get exactly what you see quoted above.
Uhm... did you read about the {eval} tag....
the default news templates use it for just the same purpose.

like I said... read the smarty manual.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Company Directory and Smarty tags (module calls) [WORKED-AROUND]

Post by jmcgin51 »

thanks Calguy - I'll revisit this issue... I've used {eval} before, but didn't know I'd need to in this case.  Looks like I need to RRTFM (ReRead TFM) ;-)
JeremyBASS

Re: Company Directory and Smarty tags (module calls) [WORKED-AROUND]

Post by JeremyBASS »

Question...  what would be the ups  and downs of using {eval}verses {capture}... any  speed difference or gain... I know that the tec note on eval is "
...Evaluated variables are compiled on every invocation, the compiled versions are not saved..
where as captures note is more on this
Be careful when capturing {insert} output...
 

But from readings, I figured that like eval(); is to be avoid in everything else, {eval} would be the same... is that not correct?

Cheers
Jeremy
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Company Directory and Smarty tags (module calls) [WORKED-AROUND]

Post by jmcgin51 »

calguy1000 wrote: Uhm... did you read about the {eval} tag....
the default news templates use it for just the same purpose.
Bingo!!  Now working just as I originally wanted.

Only thing is, now I have to decide if what I originally wanted is better or worse than the workaround I came up with...  hmmm, decisions, decisions.  Thanks again, Calguy!
Post Reply

Return to “Modules/Add-Ons”