Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

smarty v2 assign vars on more then 1 file?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Codez
Smarty Rookie


Joined: 23 Aug 2014
Posts: 7

PostPosted: Sat Aug 23, 2014 9:04 pm    Post subject: smarty v2 assign vars on more then 1 file? Reply with quote

Alright so I am trying to make a smarty page wrapper. i use .php to load most of the settings i want assigned with smarty. I also use a global file and paths file to set constants for the paths and load up smarty and other classes.

my problem is that when i goto the page i want to goto the tpl design shows up but the php in the included file is not doing any, or it is but smarty is not grabbing the data to display it.

index.php

Code:

<?php
error_reporting(E_ALL ^ E_NOTICE);
//ob_start('ob_gzhandler');
include "Global.php";
if(defined(ROOT_PTH))
{
   $root=ROOT_PTH;
}
else
{
   $root=dirname(__FILE__).'/';
}

if(defined(SMARTY_DIR))
{
   $sm=SMARTY_DIR;
   require_once($sm."Smarty.class.php");
   $smarty = new Smarty();

   $smarty->template_dir = $root.'Templates/Dev';
   $smarty->compile_dir = $root.'Templates_C';
   $smarty->cache_dir = $root.'Cache';
   $smarty->config_dir = $root.'Smarty_configs';

   $smarty->assign('page', 'index');
   $smarty->assign('title', 'ZHS GPT SCRIPT');
   $smarty->assign('css', $root.'Templates/Dev/css');
   $smarty->assign('js', $root.'Templates/Dev/js');
   $smarty->assign('img', 'Templates/Dev/images');
   $smarty->assign('cimg', 'Templates/Dev/content-images');
   $smarty->assign('page_path', 'Pages');
   $smarty->assign('mpage_path', 'Pages/Members');
   $smarty->assign('opage_path','Pages/Offers');
   $smarty->assign('ptcpage_path','Pages/PTC');
   
   $smarty->assign('fpage_path','Forum');
   
   //pages
   $smarty->assign('pf_shell', array('index','about','faq','tou','privacy'));
   $smarty->assign('pf_mem', array('login','register','account','edit_prefs','referrals','earn_history','pay_history','reported_offers','support'));
   
}
else
{
   $sm=dirname(__FILE__).'/Classes/Smarty/libs/';
   require_once($sm."Smarty.class.php");
   $smarty = new Smarty();

   $smarty->template_dir = $root.'Templates/Dev';
   $smarty->compile_dir = $root.'Templates_C';
   $smarty->cache_dir = $root.'Cache';
   $smarty->config_dir = $root.'Smarty_configs';

   $smarty->assign('title', 'ZHS GPT SCRIPT');
   $smarty->assign('site_name', 'ZHS Development');
   $smarty->assign('site_url', 'http://dev.zhsolutions.net/');
   $smarty->assign('css', 'Templates/Dev/css');
   $smarty->assign('js', 'Templates/Dev/js');
   $smarty->assign('img', 'Templates/Dev/images');
   $smarty->assign('cimg', 'Templates/Dev/content-images');
   $smarty->assign('page_path', 'Pages');
   $smarty->assign('mpage_path', 'Pages/Members');
   $smarty->assign('opage_path','Pages/Offers');
   $smarty->assign('ptcpage_path','Pages/PTC');
   
   $smarty->assign('fpage_path','Forum');
   
   //pages
   $smarty->assign('pf_shell', array('index','about','faq','tou','privacy'));
   $smarty->assign('pf_mem', array('login','register','account','edit_prefs','referrals','earn_history','pay_history','reported_offers','support'));
   
}
if(isset($_GET['module']))
{
   $_GET['module']=trim(strtolower($_GET['module']));
   $view=$_GET['module'];
}
if(!isset($view))
{
   $smarty->display('index.tpl');
}
else
{
   
   if(isset($section))
   {
      $_GET['section']=trim(strtolower($_GET['section']));
      $section=$_GET['section'];
      switch($view)
      {
         case $view;
         $cview=basename($view, '.php');
         $smarty->assign('page_header', ucfirst($cview));
         $sfile="$section_$cview.tpl";
         $fileinfo=$root."Pages/".ucfirst($section)."/".$view;
         if(file_exists($fileinfo))
         {
            include_once($fileinfo);
         }
         else
         {
            header("HTTP/1.0 404 Not Found");
            include_once($root."Pages/404.php");
         }
         break;
      }
   }
   else
   {
      switch($view)
      {
         case $view;
         $cview=basename($view, '.php');
         $smarty->assign('page_header', ucfirst($cview));
         $sfile="$cview.tpl";
         $fileinfo=$root."Pages/".$view;
         if(file_exists($fileinfo))
         {
            include_once($fileinfo);
         }
         else
         {
            header("HTTP/1.0 404 Not Found");
            include_once($root."Pages/404.php");
         }
         break;
      }
   }
}
//ob_end_flush();
?>


now then this part works but it is the php file in Pages i am having trouble with.

about.php
Code:
global $db,$smarty;
$abt=$db->select("settings_pages", "sval", ["sname" => 'about_us']);
$smarty->assign("aboutus", $abt);
$smarty->display("about.tpl");

it displays the tpl but doesn't pull the data now lets look at about.tpl

about.tpl
Code:
{include file="header.tpl"}
<!-- START small_banner -->
  <section class="small_banner">
     <div class="center-wrap">
        <p class="page-banner-heading">{$page_header}</p>
        <div id="banner-search" style="display: hidden;">
           <form method="get" class="searchform" action="#">
              <fieldset>
                 <input type="text" name="s" class="s" value="Search..." onfocus="if(this.value=='Search...')this.value='';" onblur="if(this.value=='')this.value='Search...';" />
              </fieldset>
           </form>
        </div>
        <!-- END banner-search -->
        <div class="breadcrumbs"><a href="">Home</a> &rarr; <a>Pages</a> &rarr; <span class="current_crumb">About Us </span>
        </div>
        <!-- END breadcrumbs -->
     </div>
     <!-- END center-wrap -->

     <div class="shadow top"></div>
     <div class="shadow bottom"></div>
     <div class="tt-overlay"></div>
</section>

<section id="content-container" class="clearfix">
     <div id="main-wrap" class="clearfix">
        <div class="two_third">
            <p>
            {section name=about loop=$aboutus}
                {$aboutus[about]}
            {/section}
            </p>
        </div>

        <div class="one_third">
           <div class="img-frame full-third-short"><a href="#" target="_self"><img src="{$cimg}/online-shopping-280x124.jpg" alt="Wordpress Professional Expert" width="280" height="124" /></a></div>
           <h4>filler text</h4>
           <p>Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Donec id elit non mi porta gravida at eget metus. Lorem ipsum dolor.</p>
        </div>
        <div class="column-clear">&nbsp;</div>
        <p>&nbsp;</p>

     </div>
     <!-- END main-wrap -->   
  </section>
  <!-- END content-container -->
{include file="footer.tpl"}

Please someone point out what i am doing wrong
Back to top
View user's profile Send private message
Codez
Smarty Rookie


Joined: 23 Aug 2014
Posts: 7

PostPosted: Sun Aug 24, 2014 5:49 am    Post subject: Reply with quote

NVM the smarty is working it's the db not working. thx anyways
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP