Problems, need help? Have a tip or advice? Post it here.
11 posts Page 1 of 2
Hi guys,

Ive been using the cms for a while now on a couple of sites and have to say - Im loving it - So simple and means I can build as I would normally and then add in the cms.

Right, my current site im working on, im needing to show a FAQ section and a link to a testimonial but only on certain pages.

The page is a cloned template and I included a tick boxes with the following options: Testimonials / FAQS Both and had thought of using the <cms:if > to show the sections based on the options selected.

Now, this is where im struggling. I can get the FAQ section to show on its own, I can get the testimonials to show on its own or nothing at all.. I can't seem to get both displayed when both are selected in the CMS admin....


HELP!!

This was what I have tried so far.
HTML Code

<cms:if faq ='Testimonials'>
<a href="testimonials.php">Testimonial on this course from a parent</a>
</cms:if>
<cms:if faq ='FAQs'>
<!--FAQ Accordion-->
<h1> FAQ</h1>

</cms:if>

<cms:if (faq eq 'Testimonials') && (faq eq 'FAQs') >
<a href="testimonials.php">Testimonial on this course from a parent</a>
</cms:if>

Tags:

<cms:template title='Workshop template' label='Workshop Title' clonable='1' dynamic_folders='1'>
<cms:editable name='group_content' label='Content' desc='Your Content and Description' type='group' />

<cms:editable name='short_desc' label='Short Description'
desc='Enter short desciption of News content. This shows for each listing on the News page. Limited to 100 characters.'
maxlength='100'
type='text'
group='group_content'/>

<cms:editable name='workshop_content' label='Workshop Content' desc='Enter the Workshop Content into here' type='richtext'group='group_content'/>

<cms:editable name='faq_testimonials' label='FAQs & Testimonials' desc='Select FAQ showing and also Testimonials on workshop page' type='group'/>

<cms:editable
name="faq"
label="FAQ Select"
desc="Select the options to display on Workshop page. Either Testimonials , FAQ's, Both or neither as required."
opt_values='Testimonials|FAQs | No'
type='checkbox'
group='faq_testimonials'
/>

</cms:template>

Anyone got any ideas as to what im doing wrong?

Thanks and sorry for the long winded post!
Ryan
Hi and welcome Ryan :)

Coming to the problem you mentioned -
First of all, I'd suggest you use only two options for the checkboxes -
Code: Select all
opt_values='Testimonials|FAQs' 

The third option you are using right now ('No') is redundant and will be implicit if the user does not select either 'Testimonials' or 'FAQs'.

Next, let us see how checkboxes store the selected values.
Checkboxes, by default, actually store a '|' separated string containing all the checked values.
For example, if in your case, if only 'FAQs' was selected, the following statement
Code: Select all
<cms:show faq /> 

would print
'FAQs'
but if both 'Testimonials' and ''FAQs' were selected, the value printed would be
'Testimonials|FAQs'

To extract the concatenated values, we need to use the cms:each tag (http://www.couchcms.com/docs/tags-reference/each.html)

The following code will now do what you desire -
Code: Select all
<cms:each faq >
    <cms:if item='Testimonials'>
        <a href="testimonials.php">Testimonial on this course from a parent</a>
    </cms:if>

    <cms:if item='FAQs'>
        <!--FAQ Accordion-->
        <h1> FAQ</h1>
    </cms:if>
</cms:each>

Hope this helps.
Thanks.
Thanks KK,

Will try this later once I get some time..

I knew it would be something simple I had missed..

Thanks for the help - Keep up the great work! Loving the system, exactly what I needed for my sites.

Ryan
KK - That worked a treat thanks.. :D

A couple more things.

Can the date entry format be changed from YY-MM-DD to DD-MM-YY ?? And also the validator for it to be able to include TBC??

If they can, that would be great as would make things easier for my client when it comes to adding the courses.

Thanks for all the help!

Ryan
I am glad :)

Can the date entry format be changed from YY-MM-DD to DD-MM-YY ?

I'm afraid we cannot use a different format while entering dates (displaying dates is a different matter). This has to do with how Couch internally stores dates.

And also the validator for it to be able to include TBC??

TBC, I assume, is 'To Be Confirmed'. Could you please let me know exactly what kind of validator you require?
What I did was copy the date field from the documentation.

So have this atm.

<cms:editable name='end_date'
label='Event Date (if multi-days event)'
desc='Enter Course date in yyyy-mm-dd format e.g. 2010-12-31'
type='text'
validator='regex=/(?:19|20)\d\d-(?:0[1-9]|1[012])-(?:0[1-9]|[12][0-9]|3[01])/'
separator='#'
validator_msg='regex=Incorrect date format'
/>

What I want to be able to do is along with the date, have the option to specify a date or TBC rather than no date at all as I have it currently if posible?

Also, can multiple dates be added into the same field? Im guessing not but thought id ask.. Lol

Thanks for all the help KK - Appreciated!

Ryan
Hi Ryan,

What I want to be able to do is along with the date, have the option to specify a date or TBC rather than no date at all as I have it currently if posible?

Could you please explain that a little more?
As far as I could understand, you wish to have the user input something different for TBC than the date normally entered.
Exactly what should be the format of this TBC that you mention?
Please let me know.

Thanks.
KK wrote: Hi Ryan,

What I want to be able to do is along with the date, have the option to specify a date or TBC rather than no date at all as I have it currently if posible?

Could you please explain that a little more?
As far as I could understand, you wish to have the user input something different for TBC than the date normally entered.
Exactly what should be the format of this TBC that you mention?
Please let me know.

Thanks.



No worries- Might be my explanation!

What I am needing to do if possible is - input the course date if already set OR be able to display TBC ( Just the letter) if the course date hasn't been confirmed yet.

So I was hoping in the date field in the admin, be able to either input the date of the course ie 2013-04-27 OR TBC and it would display.

Does this help?

Ryan
OK, I get it now Ryan :)
See, modifying the regex to allow 'TBC' is trivial
validator='regex=/(?:(?:19|20)\d\d-(?:0[1-9]|1[012])-(?:0[1-9]|[12][0-9]|3[01]))|(?:TBC)/'

The question is - do we really want to do this?
The fixed format of the date makes it possible for us to use the field's value to,. e.g., find events that fall before or after a particular date, sort events based on the end date etc.
By inputting 'TBC' string into the field we forsake all that.

If. however, the end-date is just used to display a date on the front-end, we can try and use 'TBC'.
Thanks KK,

Atm, the end date is just used to display the course date. It just makes it easier for my client to input the course details by having it segregated.

Just tried it - Doesn't like it and keeps giving Error message to the field if I put TBC in??

Thanks once again!

Ryan
11 posts Page 1 of 2