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

Data persistance between pages...

 
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
John
Smarty Rookie


Joined: 30 Jun 2003
Posts: 10
Location: Patong Beach Phuket Thailand

PostPosted: Fri Jul 04, 2003 5:40 pm    Post subject: Data persistance between pages... Reply with quote

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) Question

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 Question (And, if not, then is it worth using Smarty? Sad 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 Question Not so elegant, but maybe more practical!

I'm not an OOPs sort of guy (yet Cool ) and have only very recently started using PHP / MySQL but have a feeling that this application may be better suited to manipulation using objects Question 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 Embarassed 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 Evil or Very Mad .

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 Question

Thanks in advance.
John
Back to top
View user's profile Send private message Visit poster's website
BlueTrin
Smarty Rookie


Joined: 05 Jul 2003
Posts: 9

PostPosted: Sun Jul 06, 2003 4:26 pm    Post subject: Reply with quote

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
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