Using keyword replacements


(Richard Crompton) #1

Hi

 

These may seem a trivial questions, but I've only been using Squiz Matrix for a few weeks now.

 

Firstly In the Thank You Bodycopy of an online quiz I want to thank the respective user by name, i.e. either the logged in users first name or the name captured in the User Details Form.

 

Working on the proviso that the logged in user won't be presented with the user details form and therefore can assume that the name won't be entered.

 

Noting that the name is a mandatory field on the user details form.

 

I initially tried:

%globals_user_attribute_first_name^empty:user_details_form_11281-q1% - but realised the public user has a name 'Public'

 

So I switched the statement around:

%user_details_form_11281-q1^empty:globals_user_attribute_first_name% - but now I don't get a name at all!

 

Also:

%user_details_11281:q1_answer^empty:globals_user_attribute_first_name% - but no name

 

Secondly I'm having difficulty getting the question field name to appear on the user details form and had to hard code it!

 

Asset list:

 

User Details Bodycopy [11275]

User Details Form [11281]

    Format Bodycopy [11522]

    Name [11281:q1]

    Email address [11281:q2]

    Company [11281:q3]

 

Format Bodycopy:

 

 
<p style="color: #ff0000;">%form_errors%</p>
<div class="quiz">
    <div id="divleftquiz"><strong>%question_name_11275_11281:q1%</strong></div>
    <div id="divrightquiz">%form_11281_q1%</div>
    <div style="clear: both;"></div>
    <div id="divleftquiz"><strong>Email Address</strong></div>
    <div id="divrightquiz">%form_11281_q2%</div>
    <div style="clear: both;"></div>
    <div id="divleftquiz"><strong>Company Name</strong></div>
    <div id="divrightquiz">%form_11281_q3%</div>
    <div style="clear: both;"></div>
    <br />
    %submit_button% %reset_button%
</div>

 

 

Hope there's enough detail in here?

 

Richard


(Anthony) #2

Not too familair with forms. But I can tell you I misinterpreted ^empty when I first tried using it... maybe this will help you...

 

I initially assumed that %a^empty:b% meant "print out the value of a unless it is empty in which case print b"

But in fact I believe it just means "if a is empty then print b" (so if a is not empty it doesnt print anything)

You probably need a%a^empty:b%

Note theres also a ^notempty if thats helpful


(Anewport) #3

Haven't used the Online Quiz asset much but I think you need to update your keywords. If you want to use a keyword replacement in the ^empty modifier then you need to use ^replace_keywords first, however global keywords aren't supported using this, see - http://manuals.matrix.squizsuite.net/keyword-replacements/chapters/keyword-modifiers. This would account for your keywords combination returning no value at all. Maybe you could try getting the logged in user name, and if it says Public then do not show, then print the form input, e.g. %globals_user_attribute_first_name^maxwords:1^lowercase^replace:public:% where this is checking if the users name is 'public' and might not work if your users can pick any username. Probably better to use %globals_user_assetid^eq:7:% as that checks if the current user ID is 7 which is always the Public user asset number.

 

If that can't get you what you need then perhaps using a Paint Layout and detecting if a user is logged in with Conditional Keywords will serve you better, see - http://manuals.matrix.squizsuite.net/paint-layouts/chapters/conditional-keywords-screen

 

As for the second problem of the question field, you should be able to use %quiz_qX_name% where X is the field ID, see - http://manuals.matrix.squizsuite.net/online-quiz/appendices/keyword-replacements. If that fails then you can always use a global keyword in the form of %globals_asset_attribute_<attribute>:<assetid>% to become something like %globals_asset_attribute_name:123456%. You can find the Online Quiz attributes at http://manuals.matrix.squizsuite.net/online-quiz/appendices/asset-attributes

 

Hope that helps