<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } $plugin_info = array('pi_name' => 'Pre Embed', 'pi_version' => '1.0.2', 'pi_author' => 'Rob Sanchez', 'pi_author_url' => 'http://github.com/rsanchez', 'pi_description' => 'Embed a template before other tag parsing, so you can re-use templates more easily.', 'pi_usage' => Pre_embed::usage()); class Pre_embed { public $return_data = ''; public function Pre_embed() { $this->EE =& get_instance(); $this->return_data = $this->EE->TMPL->tagdata; if (preg_match_all('/' . LD . 'pre_embed\\s*=\\s*([\\042\\047]?)(.*)\\1(.*)' . RD . '/', $this->return_data, $matches)) { foreach ($matches[0] as $i => $full_match) { //template_group/template, embed vars $embed = $this->embed($matches[2][$i], $this->EE->functions->assign_parameters($matches[3][$i])); $this->return_data = str_replace($full_match, $embed, $this->return_data); } } } protected function embed($template, $vars = FALSE) { $template = explode('/', $template); $group_name = $template[0]; $template_name = isset($template[1]) ? $template[1] : 'index'; $query = $this->EE->db->select('template_data, save_template_file, template_name, template_groups.group_name, template_type')->where('group_name', $group_name)->where('template_name', $template_name)->join('template_groups', 'template_groups.group_id = templates.group_id')->get('templates'); if ($query->num_rows() === 0) { return ''; } $embed = $query->row('template_data');
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); $plugin_info = array( 'pi_name' => 'Pre Embed', 'pi_version' => '1.0.2', 'pi_author' => 'Rob Sanchez', 'pi_author_url' => 'http://github.com/rsanchez', 'pi_description' => 'Embed a template before other tag parsing, so you can re-use templates more easily.', 'pi_usage' => Pre_embed::usage() ); class Pre_embed { public $return_data = ''; public function Pre_embed() { $this->EE =& get_instance(); $this->return_data = $this->EE->TMPL->tagdata; $this->globals = $this->EE->TMPL->fetch_param('globals'); if (preg_match_all('/'.LD.'(pre_embed\s*=\s*(\042|\047)([^\2]*?)\2)((\s*\w+\s*=\s*(\042|\047)[^\6]*?\6)+)?\s*'.RD.'/ms', $this->return_data, $matches)) { foreach ($matches[0] as $i => $full_match) { //template_group/template, embed vars $embed = $this->embed($matches[3][$i], $this->EE->functions->assign_parameters($matches[4][$i])); $this->return_data = str_replace(