Znalazłem w sieci coś takiego:
Cytat
Poradnik przedstawia jak w prosty sposób sprawić że każdy kod PHP dodany w main.tpl będzie działał.
Instrukcja
1.Otwieramy plik index.php (Znajduje się w głównym katalogu DLE)
1a.Szukamy linijki
echo $tpl->result['main'];
1b.Podmieniamy ją na następującą
eval (' ?' . '>' . $tpl->result['main'] . '<' . '?php ');
2.To wszystko.Od teraz możemy dodawać kod PHP w pliku main.tpl
Instrukcja
1.Otwieramy plik index.php (Znajduje się w głównym katalogu DLE)
1a.Szukamy linijki
echo $tpl->result['main'];
1b.Podmieniamy ją na następującą
eval (' ?' . '>' . $tpl->result['main'] . '<' . '?php ');
2.To wszystko.Od teraz możemy dodawać kod PHP w pliku main.tpl
Czy możecie napisać co znaczy DLE i co zrobić jeśli nie mam takiej linijki w katalogu głównym?
Mój kod z index.php w najwyższym katalogu to:
<?php require_once "_includes/_bootstrap.php"; BugTracker::clearBug(); $timer->start('Smarty'); include (SMARTY_DIR . 'Smarty.class.php'); $smarty = new Smarty(); $smarty->assign_by_ref('link', $LinkGenerator); // recognize template directory $row = $cache->load('template_object_' . $hash); if ($row === false) { $log->debug("Loading skin info and saving it to cache: " . CONF_SKIN_DEFAULT); $select = $db->select() ->where('name = ?', CONF_SKIN_DEFAULT); $row = $select->query()->fetch(); if ($row['editable']) { $row['cat'] = "_skiny_users"; } else { $row['cat'] = "_skiny"; } } Zend_Registry::set("DEFAULT_SKIN_ID", (int)$row['id']); $cat = $row['cat']; $smarty->assign("skinyDir", $cat); $smarty->template_dir = $cat . "/" . CONF_SKIN_DEFAULT . "/html"; $smarty->compile_dir = $cat . "/" . CONF_SKIN_DEFAULT . "/cache"; $timer->stop('Smarty'); // check if shop is off { $session->off = true; } { $smarty->display("off.tpl"); $log->info("Shop is closed. Exiting..."); exit; } { $session->cat_id = ''; } $timer->start('currency.inc'); include ('currency.inc'); $timer->stop('currency.inc'); $timer->start('languages.inc'); include ('languages.inc'); $timer->stop('languages.inc'); $timer->start('user_functions.inc'); include ('user_functions.inc'); $timer->stop('user_functions.inc'); setCurrency(); $smarty->assign("lang", $session->lang); // set main_page breadcrumb Zend_Registry::get('breadcrumbs')->append(MAIN_PAGE, $LinkGenerator-> getIndexLink()); if ($session->userObject) { if (!$session->userObject->checkNotDeleted()) { $_GET['logout'] = true; } } $total = $cache->load('price_list_count_'.$session->lang); if($total === false) { ->joinInner(TABLE_PRODUCT_TRANSLATIONS, $db->quoteInto('product_id=pid AND lang=?', $session->lang), array()) ->query()->fetch(); } if($total['total']<=2000) { $smarty->assign('show_pdf', 1); } $timer->start('baner.inc'); include ('baner.inc'); $timer->stop('baner.inc'); $timer->start('bestsellers.inc'); include ('bestsellers.inc'); $timer->stop('bestsellers.inc'); $timer->start('search.inc'); include ('search.inc'); $timer->stop('search.inc'); $timer->start('login.inc'); include ('login.inc'); $timer->stop('login.inc'); $timer->start('product_list.inc'); include ('product_list.inc'); $timer->stop('product_list.inc'); $timer->start('product.inc'); include ('product.inc'); $timer->stop('product.inc'); $timer->start('subsc.inc'); include ('subsc.inc'); $timer->stop('subsc.inc'); $timer->start('panel.inc'); include ('panel.inc'); $timer->stop('panel.inc'); $timer->start('basket.inc'); include ('newbasket.inc'); $timer->stop('basket.inc'); $timer->start('change_pass.inc'); if ($_GET['change_pass'] == true) include ('change_pass.inc'); $timer->stop('change_pass.inc'); $timer->start('bottombar.inc'); include ('bottombar.inc'); $timer->stop('bottombar.inc'); $timer->start('add_ins.inc'); include ('add_ins.inc'); $timer->stop('add_ins.inc'); $timer->start('last_added.inc'); include ('last_added.inc'); $timer->stop('last_added.inc'); $timer->start('poll.inc'); include ('poll.inc'); $timer->stop('poll.inc'); $timer->start('manufactur.inc'); include ('manufactur.inc'); $timer->stop('manufactur.inc'); $timer->start('mail_to_friend.inc'); include ('mail_to_friend.inc'); $timer->stop('mail_to_friend.inc'); $timer->start('box.inc'); include ('box.inc'); $timer->stop('box.inc'); $timer->start('contact.inc'); include ('contact.inc'); $timer->stop('contact.inc'); $timer->start('podd.inc'); include ('podd.inc'); $timer->stop('podd.inc'); $timer->start('payment.inc'); include ('payment.inc'); $timer->stop('payment.inc'); $timer->start('counter.inc'); include ('counter.inc'); $timer->stop('counter.inc'); $timer->start('links.inc'); include ('links.inc'); $timer->stop('links.inc'); $timer->start('address.inc'); 1 or $_GET['type'] == 2)) include ('address.inc'); $timer->stop('address.inc'); $timer->start('wishlist.inc'); if ($_POST['wishlist'] == 1 and ValidId($_POST['pid'])) include ('wishlist.inc'); $timer->stop('wishlist.inc'); // main.php included only if $_GET is empty $timer->start('main.inc'); $smartyPage = $smarty->get_template_vars('main_page'); include ('main.inc'); $timer->stop('main.inc'); $timer->start('menu.inc'); include ('menu.inc'); $timer->stop('menu.inc'); $smarty->assign('description', $description); { $smarty->assign('error', $error); } { $smarty->assign('notify', $notify); } $smarty->assign("mainUrl", $LinkGenerator->getIndexLink()); $smarty->assign('color', 'red'); // $db->closeConnection(); // assign positioning variables { $adm_title = ""; } else { $adm_title = es($HeadConf[$session->lang]['title']); } { $adm_title .= $add_adm_title; } { $title = Zend_Registry::get('category_title'); } else { $breadcrumbs = Zend_Registry::get('breadcrumbs'); $length = $breadcrumbs->count()-1; if($length>0) { $crumb = $breadcrumbs->offsetGet($length); $title = $crumb['name']; } else { $title = ADM_TITLE; } } $smarty->assign("page_title", $title); // assign breadcrumbs $bc = Zend_Registry::get('breadcrumbs'); { $b['name'] = mb_truncate($b['name'], 25, ' ... ', false, true); $bc[] = $b; } $smarty->assign('breadcrumbs', $bc); // -- ---------------------------------------------------------- // zamias t $smarty->display('index.tpl') dajemy: // -- ---------------------------------------------------------- $timer->start('smarty compiler'); $log->debug("Smarty is compiling the template"); $smarty->display('index.tpl'); /* $btm_output = $smarty->fetch('index.tpl'); $btm_includ='./_var/btm.tpl'; if(file_exists($btm_includ)){ $btm_dopis=file_get_contents($btm_includ); $btm_c = 0; $btm_output=preg_replace('/((<\/body>)?(\s)*(<\/html>)?(\s)*)$/',$btm_dopis.'\1', $btm_output, 1 , $btm_c); if($btm_c==0)$btm_output=$btm_output.$btn_dopis; } echo $btm_output; */ // -- ---------------------------------------------------------- $timer->stop('smarty compiler'); $timer->stop(); $log->debug("Process has successfully ended in: " . $timer->get() . " s."); $log->debug("Memory Peak Usage: " . memory_get_peak_usage() . " b"); $log->info("Exiting..."); ?>