Welcome to Geeklog Sunday, October 24 2021 @ 03:49 pm EDT

Geeklog Forums

Static pages in articles


Status: offline

Pushkar

Forum User
Regular Poster
Registered: 14/04/09
Posts: 99
Location:Ukraine, Kyiv
Hello! Could it possible to show static pages under content of articles of some topics?
For example I need to add block of last topic articles after story content
 Quote

Status: offline

suprsidr

Forum User
Full Member
Registered: 29/12/04
Posts: 555
Location:Champaign, Illinois
I've been known to use the same method Chris describes in this article to pull content from other pages into my articles.

-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 29/08/05
Posts: 985
(I'm writing this without access to the source code so the details might be a bit off.)

Add a variable to your article templates: {extracontent}
In lib-custom, override CUSTOM_setTemplateVars($type, $template)
PHP Formatted Code

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);
}
 
 Quote

Status: offline

Pushkar

Forum User
Regular Poster
Registered: 14/04/09
Posts: 99
Location:Ukraine, Kyiv
I added this function to lib-custom
PHP Formatted Code

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 Frown
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 29/08/05
Posts: 985
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
PHP Formatted Code

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.
 Quote

Status: offline

Pushkar

Forum User
Regular Poster
Registered: 14/04/09
Posts: 99
Location:Ukraine, Kyiv
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

Quote by: jmucchiello

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

PHP Formatted Code

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.

 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 29/08/05
Posts: 985
1) add a second parameter to SP_returnStaticpage('pageid', 'autotag'Wink. 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;

Quote by: Pushkar

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

Quote by: jmucchiello

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:
PHP Formatted Code

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);
}
 

 Quote

Status: offline

Pushkar

Forum User
Regular Poster
Registered: 14/04/09
Posts: 99
Location:Ukraine, Kyiv
Cry Cry Cry
anything changes are here and still not working in atricle.thtml Cry

there is my code:
PHP Formatted 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);
}



Quote by: jmucchiello

1) add a second parameter to SP_returnStaticpage('pageid', 'autotag'Wink. 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;


PHP Formatted Code

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);
}
 

 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 29/08/05
Posts: 985
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.
PHP Formatted Code

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);
}
 
 Quote

Status: offline

Pushkar

Forum User
Regular Poster
Registered: 14/04/09
Posts: 99
Location:Ukraine, Kyiv
yes! it is displaying only in full story text
but still show all page of statispage but not static page content

Quote by: jmucchiello

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.

PHP Formatted Code

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);
}
 

 Quote

Status: offline

Pushkar

Forum User
Regular Poster
Registered: 14/04/09
Posts: 99
Location:Ukraine, Kyiv
jmucchiello, can you help me?
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 29/08/05
Posts: 985
I think you need to add 'autotag' as shown here, but again, I'm away from the code:
PHP Formatted Code

   $extra = SP_returnStaticpage('pageid','autotag'); // there are a few parameters here
   $template->set_var('extracontent', $extra);
}
 
 Quote

Status: offline

Pushkar

Forum User
Regular Poster
Registered: 14/04/09
Posts: 99
Location:Ukraine, Kyiv
Frown Frown Frown still displaying all page
I put the name of my autotag [staticpage_content:] instead "autotag"

Quote by: jmucchiello

I think you need to add 'autotag' as shown here, but again, I'm away from the code:

PHP Formatted Code

   $extra = SP_returnStaticpage('pageid','autotag'); // there are a few parameters here
   $template->set_var('extracontent', $extra);
}
 

 Quote

All times are EDT. The time is now 03:49 pm.

  • 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