|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
John Smarty Rookie
Joined: 30 Jun 2003 Posts: 10 Location: Patong Beach Phuket Thailand
|
Posted: Fri Jul 04, 2003 5:40 pm Post subject: Data persistance between pages... |
|
|
Hi
Suppose I have a catalogue of products. Each product has a title, description, other textual data, and an image. The user/customer uses a form to select a subset of all products for examination (and hopefully selection).
However, for presentation purposes, the products should be displayed in sets of say, five (due to image download time restrictions). Nevertheless, there may therefore be twenty pages of five products to offer for display.
My question therefore is, if I assign a complete dimensioned array of selected product template data (including image dimensions and image filenames) for all products and for all pages immediately after the user's selection, then how can that array of data persist and be available to the template, for each subsequent page load (including the scenario where the user may want to randomly page backwards and forwards between the selected product set pages)
Must I use PHP session variables to keep the data and track page numbers, or am I missing some functionality of Smarty that allows this (And, if not, then is it worth using Smarty? Although I like the idea of keeping application logic and presentation seperate, I'll be doing both on this project.) Notwithstanding, I haven't been able to find anything in the Smarty manual concerning data persistance.
Or would I be better off merely trying to keep track of the current page's five products' recordsets, and requery the database when the user selects another page Not so elegant, but maybe more practical!
I'm not an OOPs sort of guy (yet ) and have only very recently started using PHP / MySQL but have a feeling that this application may be better suited to manipulation using objects Would my assumption be correct that I may need to start getting into it? Or would my current understanding of multi-dimensional arrays suffice?
I'm not really sure I understand the concept of inheritance and all that although, as far as I know, PHP's current implementation of OOPs doesn't quite cover all of those issues yet. And maybe I don't need that functionality, do I?
Note that each product's recordset can be moderately extensive. Furthermore, PHP processing is required for each product in order to calculate prices, currency fx conversions, discover image dimensions using image filenames (so as to set up CSS layers in the template for image scrolling purposes), and other such stuff I probably haven't thought about yet .
Also, just to complicate things: a second 'companion' product (with similar subset selections possible from the display page) is required on the same page, with similar images, data, and calculated prices and currency processing requirements!
Does anyone know of any source examples, demos, or tutorials as to how these concepts might be explored?
Any of you budding applications architects out there like to donate their 2 cents on this issue
Thanks in advance.
John |
|
Back to top |
|
BlueTrin Smarty Rookie
Joined: 05 Jul 2003 Posts: 9
|
Posted: Sun Jul 06, 2003 4:26 pm Post subject: |
|
|
I second his question about persistance and include_php.
I have a variable which is used as a database handler, i'm not sure about the proper way to pass it trough all the include_php.
Here's my problem:
**db.php**
Code: |
... (many things) ...
// Make the database connection.
$db = new sql_db(HOST_DB, LOGIN_DB, PASSWORD_DB, TABLE_DB, false);
... (many things) ...
|
index.php
Code: |
<?php
... (many things) ...
$smarty->display('index.tpl');
$db->sql_close()
... (many things) ...
?>
|
**index.tpl**
Code: |
... (many things) ...
<td>{include_php file="../menu.php"}</td>
... (many things) ...
|
**menu.php**
Code: |
<?php
... (many things) ...
// get the categories
$my_query = "SELECT * FROM amusic_categorie";
if ( !($result = $db->sql_query($my_query)) ){
... (many things) ...
|
I get an error in menu.php because $db is undeclared.
Any1 could help me and tell me the best method to pass variables trough an include_php ?
For now I just put 'global $db;' in both index.php and menu.php. Is there any other method ? |
|
Back to top |
|
|
|
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
|