Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 12:05 pm EST
Geeklog Forums
Static pages in articles
suprsidr
-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
jmucchiello
Add a variable to your article templates: {extracontent}
In lib-custom, override CUSTOM_setTemplateVars($type, $template)
function CUSTOM_setTemplateVars($type, $template)
{
global $_TABLES;
if ($type != 'article') return;
$topic = DB_getItem($_TABLES['stories'], 'topic', "sid = '". $template->get_var('sid') ."'");
if ($topic != 'the right topic') return;
$extra = staticpage_generatepage('pageid'); // there are a few parameters here
$template->set_var('extracontent', $extra);
}
Pushkar
function CUSTOM_setTemplateVars($type, $template)
{
global $_TABLES;
if ($type != 'article') return;
$topic = DB_getItem($_TABLES['stories'], 'topic', "sid = '". $template->get_var('sid') ."'");
if ($topic != 'the right topic') return;
$extra = staticpage_generatepage('pageid'); // there are a few parameters here
$template->set_var('extracontent', $extra);
}
and this {extracontent} I added to article.thtml but nothing changed
jmucchiello
You need to change the strings 'the right topic' and 'pageid' to the actual values needed for your install.
I have access to the Geeklog sources now so here is an updated function. But you still have to fill in a few details: the topic_id and the staticpage_id
function CUSTOM_templatesetvars($type, $template)
{
global $_TABLES;
if ($type != 'featuredstorytext' && $type != 'archivestorytext' && $type != 'storytext') return;
$topic = DB_getItem($_TABLES['stories'], 'tid', "sid = '". $template->get_var('story_id') ."'");
if ($topic != 'the right topic') return; // you have to put the tid of the topic you want here
$extra = SP_returnStaticpage('pageid'); // there are a few parameters here
$template->set_var('extracontent', $extra);
}
AND you need to put the {extracontent} into the storytext.thtml (and featuredstorytext.thtml and archivestorytext.thtml). That will ensure it is displayed with every appearance of the story.
Pushkar
1) It displays the contents of the entire page, but I need to display only the content of static page
2) how to make this code work in article.thtml? because when I put {extracontent} in storytext.thtml it is displaying in preview of each story, but I need only in full text of story
thanks
I told you I was posting without access to the code and so some things may not be accurate. The function should be called CUSTOM_templatesetvars. Also the $type will be "featuredstorytext", "archivestorytext" or "storytext" and not "article" as I presumed.
You need to change the strings 'the right topic' and 'pageid' to the actual values needed for your install.
I have access to the Geeklog sources now so here is an updated function. But you still have to fill in a few details: the topic_id and the staticpage_id
function CUSTOM_templatesetvars($type, $template)
{
global $_TABLES;
if ($type != 'featuredstorytext' && $type != 'archivestorytext' && $type != 'storytext') return;
$topic = DB_getItem($_TABLES['stories'], 'tid', "sid = '". $template->get_var('story_id') ."'");
if ($topic != 'the right topic') return; // you have to put the tid of the topic you want here
$extra = SP_returnStaticpage('pageid'); // there are a few parameters here
$template->set_var('extracontent', $extra);
}
AND you need to put the {extracontent} into the storytext.thtml (and featuredstorytext.thtml and archivestorytext.thtml). That will ensure it is displayed with every appearance of the story.
jmucchiello
2) Put {extracontent} in the article.thtml and change the 2nd line of the function back to
if ( $type != 'article' ) return;
it is works but there some problems:
1) It displays the contents of the entire page, but I need to display only the content of static page
2) how to make this code work in article.thtml? because when I put {extracontent} in storytext.thtml it is displaying in preview of each story, but I need only in full text of story
thanks
I told you I was posting without access to the code and so some things may not be accurate. The function should be called CUSTOM_templatesetvars. Also the $type will be "featuredstorytext", "archivestorytext" or "storytext" and not "article" as I presumed.
You need to change the strings 'the right topic' and 'pageid' to the actual values needed for your install.
I have access to the Geeklog sources now so here is an updated function. But you still have to fill in a few details: the topic_id and the staticpage_id
AND you need to put the {extracontent} into the storytext.thtml (and featuredstorytext.thtml and archivestorytext.thtml). That will ensure it is displayed with every appearance of the story.
With the changes above:
function CUSTOM_templatesetvars($type, $template)
{
global $_TABLES;
if ($type != 'article') return;
$topic = DB_getItem($_TABLES['stories'], 'tid', "sid = '". $template->get_var('story_id') ."'");
if ($topic != 'the right topic') return; // you have to put the tid of the topic you want here
$extra = SP_returnStaticpage('pageid', 'autotag'); // there are a few parameters here
$template->set_var('extracontent', $extra);
}
Pushkar
anything changes are here and still not working in atricle.thtml
there is my code:
function CUSTOM_templatesetvars($type, $template)
{
global $_TABLES;
if ($type != 'article' && $type != 'storytext') return;
$topic = DB_getItem($_TABLES['stories'], 'tid', "sid = '". $template->get_var('story_id') ."'");
if ($topic != 'humor') return; // you have to put the tid of the topic you want here
$extra = SP_returnStaticpage('20080627113900520', 'staticpage_content'); // there are a few parameters here
$template->set_var('extracontent', $extra);
}
1) add a second parameter to SP_returnStaticpage('pageid', 'autotag'. I think that will work but I'm not 100% sure.
2) Put {extracontent} in the article.thtml and change the 2nd line of the function back to
if ( $type != 'article' ) return;
function CUSTOM_templatesetvars($type, $template)
{
global $_TABLES;
if ($type != 'article') return;
$topic = DB_getItem($_TABLES['stories'], 'tid', "sid = '". $template->get_var('story_id') ."'");
if ($topic != 'the right topic') return; // you have to put the tid of the topic you want here
$extra = SP_returnStaticpage('pageid', 'autotag'); // there are a few parameters here
$template->set_var('extracontent', $extra);
}
jmucchiello
Here you have to add {extracontent} back into featuredstorytext.thtml and storytext.thtml and archivestorytext.thtml. In theory, the "story_display" value is set to article when the story is rendered from article.php. But again, I'm not 100% sure.
function CUSTOM_templatesetvars($type, $template)
{
global $_TABLES;
if ($type != 'featuredstorytext' && $type != 'archivestorytext' && $type != 'storytext') return;
if ($template->get_var('story_display') != 'article') return;
$topic = DB_getItem($_TABLES['stories'], 'tid', "sid = '". $template->get_var('story_id') ."'");
if ($topic != 'the right topic') return; // you have to put the tid of the topic you want here
$extra = SP_returnStaticpage('pageid'); // there are a few parameters here
$template->set_var('extracontent', $extra);
}
Pushkar
but still show all page of statispage but not static page content
Apparently I'm hallucinating. I thought there was a call to PLG_templatesetvars() in article.php. There isn't. You could add one, but then you would have to add it everytime you upgrade. You could put in a feature request and hope they add it. Or we can go back to the older code and add another check:
Here you have to add {extracontent} back into featuredstorytext.thtml and storytext.thtml and archivestorytext.thtml. In theory, the "story_display" value is set to article when the story is rendered from article.php. But again, I'm not 100% sure.
function CUSTOM_templatesetvars($type, $template)
{
global $_TABLES;
if ($type != 'featuredstorytext' && $type != 'archivestorytext' && $type != 'storytext') return;
if ($template->get_var('story_display') != 'article') return;
$topic = DB_getItem($_TABLES['stories'], 'tid', "sid = '". $template->get_var('story_id') ."'");
if ($topic != 'the right topic') return; // you have to put the tid of the topic you want here
$extra = SP_returnStaticpage('pageid'); // there are a few parameters here
$template->set_var('extracontent', $extra);
}
jmucchiello
$extra = SP_returnStaticpage('pageid','autotag'); // there are a few parameters here
$template->set_var('extracontent', $extra);
}
Pushkar
I put the name of my autotag [staticpage_content:] instead "autotag"
I think you need to add 'autotag' as shown here, but again, I'm away from the code:
$extra = SP_returnStaticpage('pageid','autotag'); // there are a few parameters here
$template->set_var('extracontent', $extra);
}
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content