By: jcampbell
Date: 2015-03-30
Time: 15:16
|
Dynamic meta content / page title
I've got a news section set-up, with various definable fields (Title, Image, Summary), I'm trying to declare the Title as a variable that can be inserted into the <head> as the <title>, but I'm having trouble getting the data from the table:
$title_search = "SELECT Title FROM news where Page='$currentPage'";
$title_result = mysql_query($title_search,$cnx_id);
$news_title = mysql_fetch_assoc($title_result);
$TBS->MergeBlock('page_news_sql',$cnx_id,"SELECT *, Image as myimage , DATE_FORMAT(Date, '%W %D %M %Y') as FrmDate FROM news WHERE ID='$ID' ORDER BY Date DESC");
$TBS->Show() ; |
And then in my <head>
<title>[var.news_title;htmlconv='no';]</title> |
Am I right in assuming that I can't retrieve the data once MergeBlock has been run, because that only affects content in the <body>?
|
By: Skrol29
Date: 2015-03-30
Time: 23:02
|
Re: Dynamic meta content / page title
> Am I right in assuming that I can't retrieve the data once MergeBlock has been run, because that only affects content in the <body>?
It's not correct.
TBS doesn't know HTML, it doesn't care about entities <title> or <body>.
You can merge both the block and the item data wherever they are placed in the HTML template.
I think in youe snippet $news_title is an array like :
array('Title' => "My title of the news")
So the piece of template should be :
[var.news_title.Title;htmlconv='no']
better :
[onshow.news_title.Title;htmlconv='no']
|