Different summary template for questions module when answer supplied [solved]

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
davids355
Power Poster
Power Poster
Posts: 279
Joined: Fri Apr 04, 2008 10:08 am
Location: UK

Different summary template for questions module when answer supplied [solved]

Post by davids355 »

I have the questions module running on my site and I would like to have two slightly different summary templates depending whether or not the question has been answered - basically, I want the "read the answer" link to be displayed only when the question has actually been answered.

To see it please visit my site:
http://www.shareworld.co.uk it is on the home page.
Last edited by davids355 on Mon Oct 27, 2008 8:47 pm, edited 1 time in total.
Coldman
Power Poster
Power Poster
Posts: 318
Joined: Sun Jun 22, 2008 5:33 am

Re: Different summary template for questions module when answer supplied

Post by Coldman »

Hi!
I've never tried Question module but maybe it would work with this
{if isset(variable_for_answer)}answer link {else} blah blah {/if}

can you post your template here?

/Coldman
Important Code of Conduct
Why don't use CMSMS Docs or search?
Do you read Help?
Admin for Swedish Translations Team
Moderator Swedish Forum
After your problem is solved, push the green button
davids355
Power Poster
Power Poster
Posts: 279
Joined: Fri Apr 04, 2008 10:08 am
Location: UK

Re: Different summary template for questions module when answer supplied

Post by davids355 »

Heres my template:

How would I find out what the variable for answer is?

Code: Select all

<!-- Start Questions Summary Template -->
{* the get_template_vars smarty plugin, and print_r can be very useful here
   i.e: to see the fields that can be displayed, try {$itmes|print_r} *}
{if isset($formstart)}

{/if}
{foreach from=$items item=entry}
<div style="border-bottom: 0px solid; margin-bottom: 5px;">

    <p>{$entry->question}<br /><span style="font-weight: normal; color: grey;">Posted on {$entry->created|date_format} by {$entry->author}</span><br />{$entry->morelink}</p>


</div>
{/foreach}

<!--{if $pagecount > 1}
  <p>
{if $pagenumber > 1}
{$firstpage} {$prevpage} 
{/if}
{$pagenumber} {$oftext} {$pagecount}
{if $pagenumber < $pagecount}
 {$nextpage} {$lastpage}
{/if}
</p>
{/if}
-->
<!-- End Questions Summary Template -->
Coldman
Power Poster
Power Poster
Posts: 318
Joined: Sun Jun 22, 2008 5:33 am

Re: Different summary template for questions module when answer supplied

Post by Coldman »

you can put {$entry|print_r} below {foreach from=$items item=entry} in your template and refresh that page were you have the question module.

My guess it should be something like this {$entry->answer}

If that's correct then try this:

Code: Select all

{* the get_template_vars smarty plugin, and print_r can be very useful here
   i.e: to see the fields that can be displayed, try {$itmes|print_r} *}
{if isset($formstart)}

{/if}
{foreach from=$items item=entry}
<div style="border-bottom: 0px solid; margin-bottom: 5px;">

    <p>{$entry->question}<br /><span style="font-weight: normal; color: grey;">Posted on {$entry->created|date_format} by {$entry->author}</span><br /> {if isset($entry->answer)} {$entry->morelink} {else} No answer yet {/if}</p>


</div>
{/foreach}

<!--{if $pagecount > 1}
  <p>
{if $pagenumber > 1}
{$firstpage} {$prevpage} 
{/if}
{$pagenumber} {$oftext} {$pagecount}
{if $pagenumber < $pagecount}
 {$nextpage} {$lastpage}
{/if}
</p>
{/if}
-->
<!-- End Questions Summary Template -->
Important Code of Conduct
Why don't use CMSMS Docs or search?
Do you read Help?
Admin for Swedish Translations Team
Moderator Swedish Forum
After your problem is solved, push the green button
davids355
Power Poster
Power Poster
Posts: 279
Joined: Fri Apr 04, 2008 10:08 am
Location: UK

Re: Different summary template for questions module when answer supplied

Post by davids355 »

Thanks alot Coldman. That worked a treat! Much appreciated.
Post Reply

Return to “Developers Discussion”