You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am new in twig and my language is not english i just used google translate, I use twig and SQLLite to design my site, I have a series of products, each product has a tag field that stores a number of 1 to 10 tags related to that product. There is something like the following, open the product page: www.aaa.com/tagname1 or www.aaa.com/tagname1/tagname2 or www.aaa.com/etcnames/tagnameN or etc
tagname1 or tagname2 or tagname3, ... can be the name of one of those tags. With htaccess, I send requests to index.php and there I check the input parameters, now I want to know if the following method is correct or not or do you suggest a better way that has a high speed?
The method I have in mind :
On the index page, I have to get a connection with the bank and check whether the input parameter or parameters are inside the product tag or not, and for each page address that opens, I have to enter a query into the bank, and if the tag is found, the details of that product are as follows. Return an array or json that I can display in a twig template
With this method, I guess the opening speed of the site will slow down, is this method correct? Or can this work be done with better speed and optimization with the help of twig facilities?
Index.php
<?php
error_reporting(1);
require_once __DIR__ . '/plugins/twig/autoload.php';
require_once __DIR__ . '/inc/functions.php';
$url=urldecode(ltrim($_SERVER['REQUEST_URI'],'/')); // get parameters maybe 1 or more than 1 param
$param = explode( "/", $url);
$loader = new \Twig\Loader\FilesystemLoader('templates');
$twig = new \Twig\Environment($loader);
switch ($param) {
case "contact" : // for some special pages like as contacts,about,etc …
…
break;
default:
//paramintags is a function for connect to db and check tag exists then return full product details as a json or array
$r=paramintags($filename);
//If $c filled with data then echo $twig->render('pages/product.twig',array($data=>$r));
break;
}
exit;
?>
Functions.php :
<?php
error_reporting(1);
function paramintags($tag) {
// connect to database then return full product data if $tag found inside [ tag field ]
.
.
.
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
return $results;
}
?>
This discussion was converted from issue #4077 on May 06, 2024 12:16.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am new in twig and my language is not english i just used google translate, I use twig and SQLLite to design my site, I have a series of products, each product has a tag field that stores a number of 1 to 10 tags related to that product. There is something like the following, open the product page:
www.aaa.com/tagname1 or www.aaa.com/tagname1/tagname2 or www.aaa.com/etcnames/tagnameN or etc
tagname1 or tagname2 or tagname3, ... can be the name of one of those tags. With htaccess, I send requests to index.php and there I check the input parameters, now I want to know if the following method is correct or not or do you suggest a better way that has a high speed?
htaccess :
The method I have in mind :
On the index page, I have to get a connection with the bank and check whether the input parameter or parameters are inside the product tag or not, and for each page address that opens, I have to enter a query into the bank, and if the tag is found, the details of that product are as follows. Return an array or json that I can display in a twig template
With this method, I guess the opening speed of the site will slow down, is this method correct? Or can this work be done with better speed and optimization with the help of twig facilities?
Index.php
Functions.php :
Beta Was this translation helpful? Give feedback.
All reactions