Page 1 of 1

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

Posted: Mon Oct 27, 2008 7:46 am
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.

Re: Different summary template for questions module when answer supplied

Posted: Mon Oct 27, 2008 8:06 am
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

Re: Different summary template for questions module when answer supplied

Posted: Mon Oct 27, 2008 8:24 am
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 -->

Re: Different summary template for questions module when answer supplied

Posted: Mon Oct 27, 2008 9:05 am
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 -->

Re: Different summary template for questions module when answer supplied

Posted: Mon Oct 27, 2008 8:46 pm
by davids355
Thanks alot Coldman. That worked a treat! Much appreciated.