By: joshmac
Date: 2008-07-03
Time: 02:09
|
General Template + MySQL
Hello, everyone. I am new to tinybutstrong. This system is awesome.
I need a little bit of help to solve something that I can't seem to figure out.
I want to use a general template, however, all the variables are pulled from the database.
Also, I am pulling info from two mysql tables. I am trying to pull info from one
of those tables on the homepage, and the other info will be pulled from the second
table when someone clicks one of the links in the menu.
If this solution is in the manual, a point in the right direction will be helpful.
Thanks.
--
joshmac
|
By: Skrol29
Date: 2008-07-03
Time: 02:11
|
Re: General Template + MySQL
Hi Joshmac,
It depends of how are stored the variables in the database, and how you want them to be displayed.
|
By: Skrol29
Date: 2008-07-03
Time: 02:12
|
Re: General Template + MySQL
I mean, how variables are stored into the tables.
|
By: Joshua Parker
Date: 2008-07-03
Time: 02:28
|
Re: General Template + MySQL
Thanks for replying, hopefully, I can explain. The two tables I have are pages and jobs.
Pages
id
title
content
date
Jobs
id
title
description
etc.
So, for the homepage, I just have a row of links to all the job postings by title pulled from the jobs table. When someone clicks on the link, they can view the whole job posting.
Pages is controlled by the CMS part so that the administrator can add an About Us page, Contact page, etc.
Now, my database might not be designed correctly to do what needs to be done, but this project was started before I came across this great tool, so, I am cool with redoing things.
I hope this is what you were looking for. If not, please let me know. Thanks for your help.
|
By: joshmac
Date: 2008-07-03
Time: 02:51
|
Re: General Template + MySQL
I should also mention that the data I use from the pages table, is used in the template.
i.e. (blk1.title) is used at <title>[blk1.title]</title>
|
By: joshmac
Date: 2008-07-03
Time: 04:30
|
Re: General Template + MySQL
So below, is what I actually did. However, the whole thing does not work. The first part will only load the homepage if no id has been called into the browser. I need it to populate not only a list of jobs but also use the pages table to add values to the title tag of the
template, values for linkable menus such as
< a href="index.php?id=[blk1.id]" >[blk1.title]< /a>
The links work, but there are no list of jobs.
The second part calls a page when its id is called to the browser. Again, the links work,
the title of the links work, but the same title does not show up in the title tag of the
template and no content is called. I hope someone can help me extend this a little further. Thanks.
if(!$_GET['id'] && !is_numeric($_GET['id'])) {
$TBS = new clsTinyButStrong;
$TBS->LoadTemplate('TBS_templates/index.html');
$TBS->MergeBlock('blk1',$dbc,'SELECT * FROM jobs, pages');
mysql_close($dbc);
$TBS->Show();
} else {
$TBS = new clsTinyButStrong;
$TBS->LoadTemplate('TBS_templates/template.html');
$TBS->MergeBlock('blk2',$dbc,'SELECT * FROM pages');
mysql_close($dbc);
$TBS->Show();
}
|
By: joshmac
Date: 2008-07-03
Time: 20:27
|
Re: General Template + MySQL
I thought it might help if I posted what was in my html template.
<li>< a href="index.php?id=[blk3.id;]">[blk3.title;]</ a></li>
<div id="bodyPan">
<h2>[blk3.title;]</h2>
[blk3.content]
</div>
|
With regards to the first example above, this is part of the menu and links to the different pages that was created with the CMS. The problem with this one is that is only gives me the link of the first record in the database, but there are two records in the database. The div part is what the content that is posted when a user clicks on the link.
The next example below gives me all the links from the database, but none of the content is pulled from the database when a user clicks on the links.
<li>< a href="index.php?id=[blk3.id;block=li]">[blk3.title;block=li]</ a></li>
<div id="bodyPan">
<h2>[blk3.title;]</h2>
[blk3.content]
</div>
|
I am looking for a happy medium and hope that someone has the answer to my problem. Thanks in advance.
|
By: Skrol29
Date: 2008-07-07
Time: 22:52
|
Re: General Template + MySQL
Hi Joshmac,
You must have a "block=sometag" to define a zone to be repeated for each record, otherwise TBS has no zone and it merges only the first record.
When you have defines the zone, all record fields should be inside this zone. Otherwise TBS merges the last record for all fields outside the zone.
The zone can be "block=li+div", but I think it is not WC compatible.
|
By: joshmac
Date: 2008-07-09
Time: 05:20
|
Re: General Template + MySQL
Thank you.
|
|
Posting in progress.
Please wait...
|