Using variables with dynamic_title parameter
Posted: 14 January 2011 05:07 AM   [ Ignore ]
Wallflower
Rank
Total Posts:  4
Joined  2010-12-28

Is there any way to assign a variable to the dynamic_title parameter, like the logged in user’s screen name?

Profile
 
 
Posted: 14 January 2011 05:08 AM   [ Ignore ]   [ # 1 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

You should be able to do this:

dynamic_title="[some_other_field] {logged_in_screen_name}" 
Profile
 
 
Posted: 14 January 2011 05:29 AM   [ Ignore ]   [ # 2 ]
Wallflower
Rank
Total Posts:  4
Joined  2010-12-28

Thanks Rob. That kinda works, in that when I retrieve an entry after creation via the SafeCracker edit template, it’ll pull the value into the field.

But I wondered if it could actually store the value in the database on entry creation? Right now, the Control Panel shows the variable {logged_in_screen_name}.

Profile
 
 
Posted: 14 January 2011 05:31 AM   [ Ignore ]   [ # 3 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

Ah, my mistake, I forgot that dynamic_title gets encoded before that tag gets a chance to parse. You could achieve this by setting PHP to input on your template, and:

dynamic_title="[some_other_field] <?php echo $this->EE->session->userdata('screen_name'); ?>" 
Profile
 
 
Posted: 14 January 2011 05:49 AM   [ Ignore ]   [ # 4 ]
Wallflower
Rank
Total Posts:  4
Joined  2010-12-28

Ah yes, PHP input parsing works great. Thanks much Rob.

Profile