{TEASER:alias} Replacement tag

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Plauderer
Posts: 26
Joined: Tue 3. Aug 2004, 13:26

{TEASER:alias} Replacement tag

Post by Plauderer »

Hi everybody, Grüß euch!

I'm lazy so i'll post this in english only instead of german AND english. :wink:

I needed a function to retrieve an article summary directly. So i added a replacement tag called {TEASER:alias}. It returns the article summary of the aliased article using the article summary list template.

/include/inc_front/content.func.inc.php

Code: Select all

// -------------------------------------------------------------

// TEASER:alias replacement (by Ch.Kostal, 2004)
$content["all"] = preg_replace('/\{TEASER:(.*?)\}/ie', 'get_teaser_content("$1", $db);', $content["all"]);

// -------------------------------------------------------------
/include/inc_front/front.func.inc.php

Code: Select all

// -------------------------------------------------------------

// by Ch.Kostal, 2004 - returns article summary for TEASER-replacement 
function get_teaser_content ($alias, $db) {
	if($alias) {
		$sql = "SELECT acat_id FROM ".DB_PREPEND."phpwcms_articlecat WHERE acat_alias LIKE '".aporeplace($alias)."' LIMIT 1;";
		if($result = mysql_query($sql, $db)) {
			if($row = mysql_fetch_row($result)) $teaser_cat_id = $row[0];
			mysql_free_result($result);

			$teaser_article_content = get_actcat_articles_data ($teaser_cat_id, $db);
			$teaser_content = list_articles_summary ($teaser_article_content, $template_default);

			return $teaser_content;
		}
		return '';
	}
	return '';
}
I needed it and maybe some of you find it useful just the same. :wink:

Cheers, Plauderer
RHeX
Posts: 7
Joined: Thu 27. May 2004, 14:54
Location: Amsterdam
Contact:

Thanks!

Post by RHeX »

Cool feat.
gstar
Posts: 17
Joined: Thu 23. Sep 2004, 15:37
Location: Bonn

Post by gstar »

Hi,

great function. Could you tell me how to modify the output. You wrote it uses the article summary list template. How can i make the title of the article "bold" and also have the "more..." link at the end??

Thanks in advance,
gstar
Plauderer
Posts: 26
Joined: Tue 3. Aug 2004, 13:26

Post by Plauderer »

Ok, you find the template files for the article summary list in the following directory:
/phpwcms_template/inc_cntpart/articlesummary/list
under the condition that you used the default "phpwcms_template" during the installation.
There you find a "sample.tmpl" file. It shows you how to use the replacement tags within the template. I'm using this one f.e.:

Code: Select all

<div class="teaser_box"><table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">[IMAGE]{IMAGE} [/IMAGE]</td>
    <td valign="top"><div class="teaser_content">
      <h6>{SUB}</h6>
      <p>{SUMMARY}<br>
      <a href="{ARTICLELINK}">{TITLE}</a></p></div></td>
    </tr>
</table></div>
Oh, and you have to choose that template-file in the properties of the targeted article.

Hope that helps,
Plauderer
Last edited by Plauderer on Wed 29. Sep 2004, 18:12, edited 1 time in total.
gstar
Posts: 17
Joined: Thu 23. Sep 2004, 15:37
Location: Bonn

Post by gstar »

hi,

thanks for your help. but... i still got the problem that it uses

/phpwcms_template/inc_cntpart/articlesummary/article

instead of

/phpwcms_template/inc_cntpart/articlesummary/list

how can i change it???

thanks in advance!

gstar.
Plauderer
Posts: 26
Joined: Tue 3. Aug 2004, 13:26

Post by Plauderer »

My little script uses the function "list_articles_summary" which is a core function of phpwcms. It uses the articlesumary-list template. Actually i have no real idea why your installation uses the articlesummary-article template instead. :(

Have you changed anything in those functions? Make sure you have chosen the correct template file in the articles properties where it says "Template: article listing:". You should see your own template there in the drop-down box.

Plauderer
gstar
Posts: 17
Joined: Thu 23. Sep 2004, 15:37
Location: Bonn

Post by gstar »

I am sure that i didn't change anything in those functions. In the drop down i can see "Standard" which is my template and "sample.html".

But only if i make modifications in the article template it changes something. Nothing happens when changing articlesummary-list....

Perhaps i did something wrong with the integration in the article?? Could you just tell me how to correctly include the replacement tag in the article?

Thanks!
gstar
Plauderer
Posts: 26
Joined: Tue 3. Aug 2004, 13:26

Post by Plauderer »

Oh ok, the "Standard" option is no template file but the built in "template". Make a copy of the sample.tmpl and edit the copy to your like. Save it as a .tmpl file in the list folder. Then you should see it in the dropdown box.

Usage of the replacement tag is just

Code: Select all

{TEASER:alias}
Hope that helps,
Plauderer
gstar
Posts: 17
Joined: Thu 23. Sep 2004, 15:37
Location: Bonn

Post by gstar »

I also already tried this and made a "sample2.html" and had it in the drop down. But only changes in "sample2.html" in the article made also changes to the site.

Where do you put "{TEASER:alias}" in your article? In the first content part when creating the article?

In my sample2.html i just can use the {SUMMARY} tag in total. So no chance to just make the headline in bold?!

Any idea why it does still use the article template instead of the article listing? Perhaps i made something wrong creating the article itself???

Thanks a lot for your help!
gstar
Plauderer
Posts: 26
Joined: Tue 3. Aug 2004, 13:26

Post by Plauderer »

Ok, i made a complete example for you. I hope this helps:

1) I start with creating the template files in /phpwcms_template/inc_cntpart/articlesummary/list and /phpwcms_template/inc_cntpart/articlesummary/article:
http://www.kostal.at/screeny1.png

2) the list-template file contains this:

Code: Select all

<div class="teaser_box"><table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">[IMAGE]{IMAGE} [/IMAGE]</td>
    <td valign="top"><div class="teaser_content">
      <h6>{SUB}</h6>
      <p>{SUMMARY}<br>
      <a href="{ARTICLELINK}">{TITLE}</a></p></div></td>
    </tr>
</table></div>
The article-template file contains this:

Code: Select all

<div class="teaser_box"><table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">[IMAGE]{IMAGE} [/IMAGE]</td>
    <td valign="top"><div class="teaser_content"><p>{SUMMARY}</p></div></td>
    </tr>
</table></div>
3) Now i choose the template in the article:
http://www.kostal.at/screeny2.png

4) Then i use the replacement-tag in the article where i want the teaser in:
http://www.kostal.at/screeny5.png

5) So on the page with the replacement tag i get this:
http://www.kostal.at/screeny4.png

And on the actual page the summary looks like this:
http://www.kostal.at/screeny3.png


That should do it. I hope the screenshots work for you. :?:

Greetings,
Plauderer

P.S.: The screenies didn't work so i used the links instead. :(
gstar
Posts: 17
Joined: Thu 23. Sep 2004, 15:37
Location: Bonn

Post by gstar »

:( Hi Plauderer,

thank you a lot that you made yourself so much work to help me!!! Unfortunately it didn't help because i still got the same problem...

I made everything exactly how you explained it but it still takes the article template and even if i make an empty article template it still displays the article summary an the headline in the same style?!?! how can that be?

So your replacement tag works fine but it is a template problem. I also reinstalled phpwcms completely but that also didn't change anything. I don't know which template the system exactly uses.

Perhaps anybody has an idea which template that might be and how i could get the system to use the articlelist template???!!

So thank you again very much for your help and sorry that it still doesn't work out...
Greets,
gstar :roll:
Plauderer
Posts: 26
Joined: Tue 3. Aug 2004, 13:26

Post by Plauderer »

Well, as a last resort i can only offer you to take alook at your installation directly. You'ld need to give me the adress and maybe a username/password so i can look into it. We can also do it together. (Perhaps you have TeamSpeak? This way w could talk to each other)

If you want this contact me directly via my email. Use the adress i used in the forum.

Cheers, Plauderer
gstar
Posts: 17
Joined: Thu 23. Sep 2004, 15:37
Location: Bonn

Post by gstar »

Hi,

thanks! Finally the Problem is solved. Just watch out that you choose your template in the article of which the TEASER tag will be displayed and thats it.

gstar
Info
Posts: 5
Joined: Mon 18. Oct 2004, 20:27
Location: Denmark
Contact:

How do i make the teaser? (the text and the picture)

Post by Info »

Plauderer wrote:Ok, i made a complete example for you. I hope this helps:

1) I start with creating the template files in /phpwcms_template/inc_cntpart/articlesummary/list and /phpwcms_template/inc_cntpart/articlesummary/article:
http://www.kostal.at/screeny1.png

2) the list-template file contains this:

Code: Select all

<div class="teaser_box"><table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">[IMAGE]{IMAGE} [/IMAGE]</td>
    <td valign="top"><div class="teaser_content">
      <h6>{SUB}</h6>
      <p>{SUMMARY}<br>
      <a href="{ARTICLELINK}">{TITLE}</a></p></div></td>
    </tr>
</table></div>
The article-template file contains this:

Code: Select all

<div class="teaser_box"><table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">[IMAGE]{IMAGE} [/IMAGE]</td>
    <td valign="top"><div class="teaser_content"><p>{SUMMARY}</p></div></td>
    </tr>
</table></div>
3) Now i choose the template in the article:
http://www.kostal.at/screeny2.png

4) Then i use the replacement-tag in the article where i want the teaser in:
http://www.kostal.at/screeny5.png

5) So on the page with the replacement tag i get this:
http://www.kostal.at/screeny4.png

And on the actual page the summary looks like this:
http://www.kostal.at/screeny3.png


That should do it. I hope the screenshots work for you. :?:

Greetings,
Plauderer

P.S.: The screenies didn't work so i used the links instead. :(
How do i make the teaser? (the text and the picture)http://www.strandvejit.dk/cms/index.php?id=9,62,0,0,1,0
Regards
Thomas Pilegaard
Plauderer
Posts: 26
Joined: Tue 3. Aug 2004, 13:26

Post by Plauderer »

It is the summary of an article. It works like the article list. You make the summary in the preferneces of the article itself. There you can also add the picture for the summary/article.
Plauderer
Post Reply