Jump to content
xisto Community

trueteflon

Members
  • Content Count

    2
  • Joined

  • Last visited

Everything posted by trueteflon

  1. Ok so either my problem wasn't clear, or nobody is bothered to help, either way i found my answer and hopefully this helps others in the future.In joomla 1.5.x if you wanted to access a parameter from your template or even a component you can use the followingglobal $mainframe$com_params = $mainframe->getParams('com_component_name');/*would allow you to get the parameters from that particular component eg com_content is for the article parameters*/OR$template_params =$mainframe->getParams(JFile::read('templates/template_name/params.ini');$specific_template_param = $template_params->get('specific_param_name');
  2. THE PROBLEM ---------------------- More recently I was working on a website that used the Joomla 1.5 and the template had various parameters I wanted to access from inside of another component in Joomla called "Jumi"(used to insert custom html,css,php code inside of content). Normally from inside the index.php file of the template to access the parameters there you use PHP and specific Joomla "code". Now I am not a 100% sure how the inner workings are but the php code is as follows. <?php// no direct accessdefined( '_JEXEC' ) or die( 'Restricted access' );$this->setGenerator('');$threeCols = !!$this->countModules('right');//$homepage = JRequest::getVar('view') == 'frontpage';$subpath = substr(JURI::getInstance()->toString(), strlen(JURI::root())-1);$homepage = $subpath=='/';$page_list_params = $this->params->get( 'page-list' );$page_list = explode(',',$page_list_params);if(in_array($subpath,$page_list)){ $print=null;}else{ $print=true;}$http_host = strtolower($_SERVER['HTTP_HOST']);$domain = explode('.',$http_host);$subdomain_params = $this->params->get( 'branded-list' );$subdomain = explode(',',$subdomain_params);$company = null;if(in_array($domain[0],$subdomain)){$company=$domain[0]; if($company=='jet') { $company='air'; }}?> So I separated the code into a file called helper.php and place the php in there and to obtain it inside the index.php used require("templates/travel/helper.php"); and it works fine. However when I do a require from inside of Jumi to use the file, it causes the template not to display anything. Now i assume that it is because of the use of statements such as $subdomain_params = $this->params->get( 'branded-list' ); and that the $this variable is offsetting the php. Now I fixed the problem by modifying how the php obtains the parameters by using file get contents() and preg_match() with regular expressions to match what i am looking for. So now the new code looks like the following. <?php /*This file was created to separate the bulk of the php code from the html and make the variables of the Travel template * accessible for use outside of the template while not affecting the manner in which the template displays. Main use is to * be called by Jumi component/module/plugin to get the value of $company so it can be echo inside the content and choose * which module positions to load inside of Content Articles similar to in the template.*/$parameters = file_get_contents("templates/travel/params.ini");$subpath = substr(JURI::getInstance()->toString(), strlen(JURI::root())-1);$homepage = $subpath=='/';preg_match('/page-list=(\S*)/', $parameters, $matches1);$temp1=$matches1[1];$page_list = explode(',',$temp1);if(in_array($subpath,$page_list)){ $print=null;}else{ $print=true;} $http_host = strtolower($_SERVER['HTTP_HOST']);$domain = explode('.',$http_host);preg_match('/branded-list=(\S*)/', $parameters, $matches2);$temp2=$matches2[1];$branded_list = explode(',',$temp2);$company = null;if(in_array($domain[0],$branded_list)){$company=$domain[0]; if($company=='jet') { $company='air'; }}?> So the now it works fine and i can just use the same require() inside of jumi to get access to the php and variables. THE QUESTION -------------- Is there another way to get the parameters of a template to be used outside of that template in a module or component? I tried using JParameter and JTemplate but was unsuccessful.
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.