Member customfield as variable in safecracker tag
Posted: 11 November 2010 10:07 PM   [ Ignore ]
Wallflower
Rank
Total Posts:  9
Joined  2010-10-18

hi

made a membercustomfield called ‘memblang’ (de, fr or it) as a language-identifier for global variables.

in the head i place

<?php $memberlang "{exp:member:custom_profile_data}{memblang}{/exp:member:custom_profile_data}" ?> 

when i put out the variable in the template like this

<?php echo $memberlang ?> 

it showes me de, fr or it like it should

if i use the echo in the safecracker-tags it gives me the screenname in a <dd> tag
like: <dd>Res Naegeli</dd>
very strange

Code looks like this

{exp:safecracker channel="gruppenlisten" return="/stats/grouplist" safecracker_head="no" }
    
<div class="hiddenFields"
        <
input type="hidden" name="title" id="title" value="{group_title}_{entry_date}" />
        <
input type="hidden" name="gruppe" id="gruppe" value="{group_description}" />
        <
input type="hidden" name="entrydate" id="entrydate" value="{entry_date}" />    
        <
input type="hidden" name="user" id="user" value="{username}" />    
    </
div>
        
{custom_fields}
        {if safecracker_file}  
            {display_field}
        {
/if}  
        {
/custom_fields}
        
<input type="submit" name="submit" id="submit" class="submit" value="{senden_<?php echo $memberlang; ?>}" /> 
    
{/exp:safecracker} 

if i use no globalvariable {memblang} and use instead ‘it’ it makes no difference.

any idea what i’m doing wrong?

using safecracker - Build 20101102
EE 2.1.1 - Build 20101020

Profile
 
 
Posted: 11 November 2010 10:41 PM   [ Ignore ]   [ # 1 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

It’s a parse order issue. For your first snippet of code, you would need PHP on output (to get the value of EE tags). But in your safecracker code, you would need PHP on input to process the {senden_} tag properly. So, it’s not possible to do what you’re doing here.

You could probably do this:

<input type="submit" name="submit" id="submit" class="submit" value="<?php if ($memberlang == 'it') : ?>{senden_it}<?php else if ($memberlang == 'fr') : ?>{senden_fr}<?php else : ?>{senden_de}<?php endif; ?>" /> 
Profile