Jump to content

Not sure how to store files and how to display them.


Perry|

Recommended Posts

Hello.

 

I am not sure how to store files for my site and then display them. I have installed Smarty on my server for templates. My site is guide based and I want to keep the URL's short and identify them with ?id= (http://www.myurl.com/guide.php?id=1)

 

Those not familiar with Smarty, you create a template (.tpl file) and add areas in the template that you edit in your main file (index.php or whatever)

 

This is what I have in my index.php file currently

 

<?php
require 'smartyconfig/libs/Smarty.class.php';

$smarty = new Smarty;

$smarty->assign('title','Home');
$smarty->assign('main','THIS IS WHERE MAIN CONTENT WILL GO');
$smarty->display('index.tpl');
?>

 

So basically anything in 'main' needs to be dynamic.

 

So any ideas on how to achieve this please post them, if you are unsure about anything please ask me!

 

I have subscribed to this topic so I will get back to you within ~20 minutes.

 

Many thanks,

 

Perry

 

Link to comment
Share on other sites

The page content is stored in a database table - correct?

You would select the record from your URL id, then pass it to Smarty so:

 

$query = mysql_query("SELECT field FROM table WHERE id='".$_GET['id']."' LIMIT 1");
$result = mysql_fetch_array($query);

$smarty->assign('main', $result['field']);

Link to comment
Share on other sites

The page content is stored in a database table - correct?

You would select the record from your URL id, then pass it to Smarty so:

 

$query = mysql_query("SELECT field FROM table WHERE id='".$_GET['id']."' LIMIT 1");
$result = mysql_fetch_array($query);

$smarty->assign('main', $result['field']);

No it's not that's what I'm asking, where should I store the content? In mySQl? In files?

 

Also the Title needs to be dynamic with the content too.

Link to comment
Share on other sites

Store it wherever you like. In text files is more difficult if the title needs to be extracted as a separate piece of data.

In mysql you could have a page content table with fields pageId, title, content

 

Then your page title is sent to the template:

$smarty->assign('title', $row['title']);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.