CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge -> General/Other

 Put Templates into Database (not static HTML files)

Print topic Send  topic

Author Message
Rip
Posted: 06/18/2004, 2:18 PM

I want to put the templates into the DB intead of having 30+ static HTML files to handle. How can we go about chaning the Template.php file to do this?
StevenD
Posted: 06/20/2004, 12:09 PM

Why do you not use a giant html enabled label area in the page, and keep your page html in a database field.

I reckon if you made a simple two page edit page set with the wizards against a database like this:

(custom_pages table)
page_id,
page_name,
header_section,
body_section,
footer_section,
menu_link_name,
menu_position_num,
menu_id,
datetime,
owner_user_id,
active_y_n,
show_front_page_y_n,
hits.

then you could admin all the content you needed into the single table

this would allow for a page with all items called from the url

index.php?page_id=4

put a single label field central as visable on the page, with all other needed items as hidden in the form with menu's forms at the side or top
for the central label field use custom php to build the page

do an sql select for the items needed for your custom page

check first with an if statement if the page_id = 4 is a page which is marked as 'active_y_n = 1'

if it is

select * from custom_pages where page_id=4

if it isnt, send the user back to the front page or an error page with an echo of the header (page ) etc

add into the custom php

$fldcustom_label = "<table> etc etc etc". $fldheader_section ."etc etc etc etc etc". $fldbody_section ."etc etc etc etc etc". $fldfooter_section ."etc etc</table> ";

that will show 'only what you want, html wise, with the content from any page 'from the database.

you really need a menu database to hold the menu links etc etc , but with just these simple pages, not more than maybe 6 pages in total, you could run a whole website as index.php?page_id=xx

I am sure you get the idea

hope thats what you were looking for

:)

Steven Dowd
Rip
Posted: 06/21/2004, 1:52 PM

Steven thanks,

But I do not want ANY html /tpl files at all. JUST THE php files only ( and no, I do not want to use CC to create the project with just PHP where it embeds the HTML into the *.php page. Editing the templates would be a nightmare-)

I received this from support without further explanation on how to do it:

Quote :
You should modify load_file function in template.php externally.
In this function instead of call to file_exists($template_path) you can look up
this file name in the database (using php mysql functions).
The content of this file should be saved to string variable and this variable
should be assigned to $this->DBlocks[$sName]

Regards,
Alex


Do you know what Alex is suggsting to do? I dont since I have no idea on how to edit functions.
Rip
Posted: 06/21/2004, 2:00 PM

Addendum:

Basically, I' ll havea table in the Mysql called
templates

with template_id and template as the rows

template_id will just be the "number"
template column will contain the "content" of the .html file created

For example

series.php creates series.html (template file)
I'll copy series.html content to the MYSQL table ( so itll be assigned template_id of 1 an the template will contain the HTML that was in series.html)
Rip
Posted: 06/21/2004, 8:20 PM

Do anyone from codecharge support ever visit these forums?

So Steven suggests to modify this bit of coding

  
function load_file($filename, $sName)  
  {  
    $nName = "";  
    $template_path = $this->templates_root . "/" . $filename;  
    if (file_exists($template_path))  
    {  
      $this->DBlocks[$sName] = join('',file($template_path));  
      $nName = $this->NextDBlockName($sName);  
      while($nName != "")  
      {  
        $this->SetBlock($sName, $nName);  
        $nName = $this->NextDBlockName($sName);  
      }  
    }  
  }  
  

1) where do I inject the SQL query to instead of do a "file exist" but to query the template table for template name and use the content :

ie "SELECT template FROM table WHERE name='$templatte_filename'"

Where template holds the html that was in the .html template file
table = the table where the templates will now be stored
name = name of the templates (using the original template filename, ie blah.html is the name of the template)
StevenD
Posted: 06/28/2004, 4:44 PM

Maybe I mis-understood your original posting

I thought you wanted to hold the "content " HTML in the database

as pages

not the 'html' code out of the template files

I was describing a way to build a pure php website,

not php+templates

which held the pages content in the database ready formatted, ready built, and requested vai a single database request, not built on the fly by many requests.

sorry

Steven Dowd
StevenD
Posted: 06/28/2004, 4:45 PM

you are using 'codecharge' and not 'codecharge studio'?

because in codecharge you can publish just php, in codecharge studio, you do not get this option.

?

Steven Dowd
Steven

Posts: 15
Posted: 08/09/2004, 6:04 AM

Rip

did you figure this ?

did you manage to hold the template data in the database ?

how did you publish the template file 'into' the database at publish time ?

thanks

StevenD
_________________

View profile  Send private message
shad
Posted: 12/13/2004, 12:15 PM

hello
i want to ask about how to i put php files into my website if you know any thing about it please email me back to shad_rashid@yahoo.co.uk.

thank you...

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.