tempest Smarty n00b
Joined: 22 Aug 2021 Posts: 1
|
Posted: Sun Aug 22, 2021 3:40 pm Post subject: cache issue - modified shop system |
|
|
Hi all,
we use a shop system (modified shop) with smarty 3.x
Our problem, we have a "plugin" that is working so far, but we dont want it to be cached.
All we tried failed so far....we tried {dynamic} XXX {/dynamic} as explained on smarty.net but get an error that dynamic is unknown....
This is the Code for our smarty
Code: | <?php
/* TTO
------------------------------------------------------------------------------
$Id: function.tt_random.php, v0.1 13.03.2008 11:00:00 TTO $
Random Products für XT:Commerce 3.04 SP2.1 und andere
Copyright (c) 2008 Timo-Tell Oswald
www.ctm21.de | tt.oswald@ctm21.de
Released under the GNU General Public License
------------------------------------------------------------------------------
Paypal-Spenden willkommen: donation@ctm21.de
------------------------------------------------------------------------------
LICENSE
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License (GPL)
as published by the Free Software Foundation;
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To read the license please visit http://www.gnu.org/copyleft/gpl.html
------------------------------------------------------------------------------
based on:
(c) 2000-2001 The Exchange Project (earlier name of osCommerce)
(c) 2002-2003 osCommerce - www.oscommerce.com
(c) 2003 nextcommerce - www.nextcommerce.org
(c) 2003 XT-Commerce - www.xtcommerce.com
Released under the GNU General Public License
------------------------------------------------------------------------------
*/
/* TTO
Kernfunktion tt_random
Aufruf im Template über {tt_random parameter="text"}
Mögliche Parameter und Folgen
max => Wert => Maximale Anzahl an Zufallsartikeln
tpl => String => Template, wird im Unterordner tt_plugins gesucht
Namenskonvention: tt_random_tpl.html
Beispiel:
{tt_random tpl="zweispaltig"}
=> tt_random_zweispaltig.html
cat => CatID => Kategorie
NEU Durch Kommata getrennte Liste
leer oder 0 => Nur die Aktuelle Kategorie
=> Alle, wenn keine Kategorie aktiv
catex => CatID => Kategorie, die auszuschließen ist
NEU Durch Kommata getrennte Liste
ToDo
subcat => true => Unterkategorien einbeziehen
*/
function smarty_function_tt_random($params, &$smarty) {
/* TTO
Hier Standardwert für die Anzahl der auszugebenden Angebote definieren*/
$tt_default_limit = 4;
/* TTO
Hier Standardsortierungfestlegen
"rand" => Zufall
"datedesc" => neueste zuerst
"remaining" => noch nicht implementiert
*/
/* TTO
Anzahl der Auszugebenden Angebote */
if( (int) $params['max']){
$tt_q_limit = 'LIMIT '. $params['max'];
} else {
$tt_q_limit = 'LIMIT '. $tt_default_limit;
}
/* TTO
Überprüfung, ob alle Angebote ausgegeben werden sollen */
if($params['all']== 'true'){
$tt_q_limit = '';
}
/* TTO
FSK */
$fsk_lock = '';
if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') {
$fsk_lock = ' AND p.products_fsk18!=1';
}
/* TTO
Group-Check */
if (GROUP_CHECK == 'true') {
$group_check = " AND p.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 ";
}
/* TTO
Ist eine Kategorie auszuschließen?*/
if($params['catex']){
$tt_catexarray = explode(',',$params['catex']);
$tt_catexcount = count($tt_catexarray);
$tt_catexclude='';
if($tt_catexcount==1){
$tt_catexclude = 'AND p2c.categories_id !="'. $params['catex'].'" ';
} else{
$tt_catexclude='';
foreach($tt_catexarray as $tt_catex){
$tt_catexclude .= 'AND p2c.categories_id !="'.$tt_catex.'" ';
}
}
}
/* TTO
Zufallsprodukte holen
Wenn keine cat übergeben, schauen, wo man ist
und entweder aktuelle Kategorie oder alles ausgeben */
if(!$params['cat']){
$tt_cPath = preg_replace('/[^0-9_]/','',$GLOBALS['cPath']);
$tt_category_path = explode('_',$tt_cPath);
$tt_category_id = array_pop($tt_category_path);
if($tt_category_id){
$tt_selectcat = 'AND p2c.categories_id ="'.$tt_category_id.'" ';
$tt_random = tt_random_get_byCategory($tt_q_limit, $fsk_lock, $group_check, $tt_selectcat, $tt_catexclude);
} else {
$tt_random = tt_random_get($tt_q_limit, $fsk_lock, $group_check, $tt_catexclude);
}
} else {
/* TTO
Kategorie-Liste*/
$tt_catarray = explode(',',$params['cat']);
$tt_catcount = count($tt_catarray);
if($tt_catcount==1){
$tt_selectcat = 'AND p2c.categories_id ="'. $params['cat'].'" ';
$tt_random = tt_random_get_byCategory($tt_q_limit, $fsk_lock, $group_check, $tt_selectcat, $tt_catexclude);
} else {
$i=0;
$tt_selectcat ='AND ( ';
foreach($tt_catarray as $tt_cat){
$i++;
$tt_selectcat .= 'p2c.categories_id ="'.$tt_cat.'" ';
if($i<$tt_catcount){
$tt_selectcat .= 'OR ';
}
}
$tt_selectcat .= ')';
$tt_random = tt_random_get_byCategory($tt_q_limit, $fsk_lock, $group_check, $tt_selectcat, $tt_catexclude);
}
}
/* TTO
hier aufhören, wenn keine Artikel */
if(!$tt_random){
return false;
}
/* TTO
Template prüfen
und bei nicht vorhandenem Parameter das Default-Template wählen */
if(!$params['tpl']){
$params['tpl'] = 'default';
}
$tt_random_template = tt_random_getTemplate($params['tpl']);
/* TTO
Smarty-Objekt initialisieren */
$tt_random_smarty = new smarty;
/* TTO
Admin-Warnungen ausgeben */
if ($_SESSION['customers_status']['customers_status_id'] == 0){
if($tt_random_template['warning']){
$tt_random_smarty->assign('ADMINWARNING', $tt_random_template['warning']);
}
}
/* TTO
Standardwerte zuweisen */
$tt_random_smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');
$tt_random_smarty->assign('language', $_SESSION['language']);
/* TTO
Ergebnis zuweisen */
$tt_random_smarty->assign('tt_random', $tt_random);
$tt_random_smarty->assign('tt_catex', $tt_catexclude);
/* TTO
Ergebnis ausgeben */
$output = $tt_random_smarty->fetch($tt_random_template['tpl']);
return $output;
}
/* TTO
Standardabfrage Zufallsartikel */
function tt_random_get($tt_q_limit, $fsk_lock, $group_check, $tt_catexclude){
$tt_rand = new product();
$tt_random_query = "SELECT DISTINCT p.products_id,
pd.products_name,
p.products_price,
p.products_tax_class_id,
p.products_image,
p.products_fsk18 from ".TABLE_PRODUCTS." p, ".TABLE_PRODUCTS_DESCRIPTION." pd, ".TABLE_PRODUCTS_TO_CATEGORIES." p2c
WHERE p.products_status = '1'
AND p.products_id = pd.products_id
AND p2c.products_id = p.products_id "
.$tt_catexclude."
".$group_check."
".$fsk_lock."
AND pd.language_id = '".(int) $_SESSION['languages_id']."'
ORDER BY RAND()". $tt_q_limit;
$tt_random_query_do = xtDBquery($tt_random_query);
$tt_random=array();
while ($tt_random_q_result = xtc_db_fetch_array($tt_random_query_do)) {
$tt_random[] = $tt_rand->buildDataArray($tt_random_q_result);
}
return $tt_random;
}
/* TTO
Zufallsartikel aus einer bestimmten Kategorie */
function tt_random_get_byCategory($tt_q_limit, $fsk_lock, $group_check, $tt_selectcat, $tt_catexclude){
$tt_rand = new product();
$tt_random_query = "SELECT DISTINCT p.products_id,
pd.products_name,
p.products_price,
p.products_tax_class_id,
p.products_image,
p.products_fsk18
FROM ".TABLE_PRODUCTS." p, ".TABLE_PRODUCTS_DESCRIPTION." pd, ".TABLE_PRODUCTS_TO_CATEGORIES." p2c
WHERE p.products_status = '1'
AND p.products_id = pd.products_id
AND p2c.products_id = p.products_id "
.$tt_selectcat
.$tt_catexclude
.$group_check
.$fsk_lock."
AND pd.language_id = '".(int) $_SESSION['languages_id']."'
ORDER BY RAND()". $tt_q_limit;
$tt_random_query_do = xtDBquery($tt_random_query);
$tt_random=array();
while ($tt_random_q_result = xtc_db_fetch_array($tt_random_query_do)) {
$tt_random[] = $tt_rand->buildDataArray($tt_random_q_result);
}
return $tt_random;
}
/* TTO
Nachsehen, ob das angegebene Template existiert
Notfalls das mitgelieferte ausgeben */
function tt_random_getTemplate($tpl){
$tt_random_template = array();
$tt_tpl_tocheck = 'tt_random_' . $tpl . '.html';
/* TTO
Wenn Template existiert, dann zurückgeben und gut is */
if (file_exists('templates/' . CURRENT_TEMPLATE . '/module/tt_random/' . $tt_tpl_tocheck)){
$tt_random_template = array('tpl' => CURRENT_TEMPLATE . '/module/tt_random/' .$tt_tpl_tocheck);
return $tt_random_template;
}
/* TTO
Wenn Template nicht existiert und nicht default hieß,
dann nochmal nach dem default schauen */
if($tpl!='default'){
if (file_exists('templates/' . CURRENT_TEMPLATE . '/module/tt_random/tt_random_default.html')){
$tt_random_template = array('tpl' => CURRENT_TEMPLATE.'/module/tt_random/tt_random_default.html',
'warning' => 'Das angegebene Template tt_random_'.$tpl.'.html existiert nicht!');
return $tt_random_template;
}
}
/* TTO
Wenn wir jetzt immer noch nicht zurück sind,
fehlen die Templates komplett */
if($tpl='default'){
$tt_random_template = array('tpl' => 'tt_default/tt_random/tt_random_default.html',
'warning' => 'Es existiert kein Template für die Ausgabe der Zufallsartikel!');
return $tt_random_template;
}
return false;
}
?>
|
Maybe someone can help to make this code not cached...
Best
Jürgen |
|