Published by Mijingo

tips icon image

EE Insider Tips
Sponsored by Mijingo's EE 2 Screencasts

ExpressionEngine mini-howtos created by the EE Insider community.

Make embedded params tag params.

User's avatar
  • Posted by Leevi Graham
  • November 08, 2009
  • 1 person has found this tip helpful.

You can access embed params directly in your plugin code. This is super useful when you include a plugin / module inside an embedded template and need to pass through params.

<?php 
 
// http://gist.github.com/204612

make_embed_params_tag_params()
{
    
// the valid params for the tag
    
$valid_params = array(
        
'entry_id',
        
'weblog_id',
        
'url_title'
   
);
 
    
// for each of the embedded params
    
foreach ($TMPL->embed_vars as $key => $value)
    
{
        
// parse the param key
        // embed: ... 
        
$param_key substr($key6);
        if(
            
// is the tag param actually set?
            
isset($TMPL->tagparams[$param_key]) === FALSE
            
// is the embbed param in the valid params array?
            
&& in_array($param_key$valid_params)
        )
        
{
            
// add the embed param to the tag param
            
$TMPL->tagparams[$real_key] $value;
        
}
    }

Add Your Comment?

You must have an EE Insider account to post comments on Insider Tips. It's fast, easy and hassle-free.

Sign up now (or login).

Search EE Insider Tips
Sponsored By