Extended {RELATED...} tag

Use GitHub to post feature requests for phpwcms.
Locked
User avatar
Oliver Georgi
Site Admin
Posts: 9907
Joined: Fri 3. Oct 2003, 22:22
Contact:

Extended {RELATED...} tag

Post by Oliver Georgi »

Hi

I'm working on a new site for a customer and found one thing missing:

{RELATED...} replacement tag but also with custom given keyword. As for now only the keywords of the current articles are used. I extended this - very simple thing. If you want to use also:

{RELATED:INT_COUNT:keyword1, keyword2,...}

INT_COUNT = how many related articles should be listed.
Keywords can be splitted by " " or "," or ";"

In content.func.inc.php change around line 347 to (line 353 is new):

Code: Select all

// related articles based on keywords, inspired by Magnar Stav Johanssen
if( ! ( strpos($content["all"],'{RELATED:')===false ) ) {
	if (!$no_content_for_this_page && $content["articles"][$aktion[1]]["article_keyword"]) {
		$related_keywords = $content["articles"][$aktion[1]]["article_keyword"];
	}
	$content["all"] = preg_replace('/\{RELATED:(\d+)\}/e','get_related_articles($related_keywords,$aktion[1],$template_default["related"],"$1",$db);',$content["all"]);
	$content["all"] = preg_replace('/\{RELATED:(\d+):(.*?)\}/e','get_related_articles("$2",$aktion[1],$template_default["related"],"$1",$db);',$content["all"]);
}
Oliver
Last edited by Oliver Georgi on Thu 8. Mar 2007, 15:55, edited 1 time in total.
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Florian
Posts: 119
Joined: Wed 19. Nov 2003, 16:50
Location: Hamburg
Contact:

Post by Florian »

Hi Oliver!

This is a very nice thing.
By me it doesn't work. When I use the RELATED Tag, I got back the value which I entered behind the ':'. Exp.: {RELATED:Newsticker} gives back at output [...] Newsticker[...]. If I choose the {KEYWORD} replacement tag I've got the same problem. Is there something I made wrong?
To me it seems, that the "RELATED" tag seaches for all artices which contains the given keyword in their "Keywords" field in the propertys of the article in the article center. The "KEYWORD" option brings back all data which contains the given keyword within the article body, right?

Cheers,
Florian
User avatar
Oliver Georgi
Site Admin
Posts: 9907
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

Yes and no:

The related replacement tags are used like this:

{RELATED:RESULT_COUNT} where RESULT_COUNT (INT) = how many results of found related articles should be listed. RESULT_COUNT = 0 all will be listed. When you choose related current article keywords will be used to find related articles with same keywords based on OR query.

Another new replacement tag is {NEW:RESULT_COUNT} where RESULT_COUNT (INT) = how many new articles should be listed.

Have a look at conf.template_default.inc.php to find special formatting values.

{KEYWORD:MY_KEYWORD} where MY_KEYWORD (STRING) = the keyword that is a special marked one in article keyword field. These keywords have to be set as this *MY_KEYWORD* in keyword field - NOT in the replacement tag. It returns an link to the found article. If more than 1 article was found the result looks like MY_KEYWORD [1|2|3...] where the number is an link to an article. You should use {KEYWORD...} in texts.

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Florian
Posts: 119
Joined: Wed 19. Nov 2003, 16:50
Location: Hamburg
Contact:

Post by Florian »

Hello Oliver!

Now I got it. Everything works. Excepting the {KEYWORD:MY_KEYWORD} one.
I tryed several combinitions of it. Can you may be explain it in German, what it is and for what it's made for?
Only in a few words. I'll will repost it in my own english words. Maybe it's more easyer other users (and me of course;)) to understand this usefull option :D.

Cheers,
Florian
User avatar
Oliver Georgi
Site Admin
Posts: 9907
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

OK,

also KEYWORD ist dafür da, dass bestimmte Schlüsselwörter innerhalb eines beliebigen Textes dazu genutzt werden können, direkte Links auf gleiche Artikel anzubieten. Also Du hast gerade was neues zu Deinem Unternehmen geschrieben und möchtest aber mit MEIN_UNTERNEHMEN alle im System vorhandenen Informationen damit verlinken. Dann fügst Du in den laufenden Text das Replacament Tag ein {KEYWORD:MEIN_UNTERNEHMEN}. Damit aber phpwcms jetzt dieses Schlüsselwort finden kann, muss dieses explizit im Feld Schlüsselwörter eines Artikels als quasi höherwertiges Schlüsselwort markiert werden. Dazu muss es dort mit "*" umfaßt werden = *MEIN_UNTERNEHMEN*. Das machst Du in allen Artikeln, die als relevantes Schlüsselwort genau dieses haben sollen. Wird nur ein passender Artikel gefunden, wird das Replacament Tag mit dem Link <a href="meinartikel">MEIN_UNTERNEHMEN</a> ersetzt. Wird mehr efunden, wird eine Linkliste zurückgeliefert: MEIN_UNTERNEHMEN [<a herf="meinartikel_1">1</a>|<a herf="meinartikel_2">1</a>...]

OK, hoffe das ist jetzt klarer.

Möglicherweise ist aber auch sinnvoll das auf vollautomatische Füße zu stellen. Also einfach immer alle verfügbaren Schlüsselwörter in einem Array zusammenzufassen und diese dann beim Seitenrendering enstprechend automatischim Text suchen und ersetzen zu lassen.

Gruß
Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
rk
Posts: 162
Joined: Sat 24. Apr 2004, 23:48
Location: Hannover, Germany
Contact:

Wish: more extended {RELATED...} tag

Post by rk »

I would like to have an more extended related tag ;-).

I think a combination from new and related would be very usefull.

{RELATED:INT_COUNT:keyword1, keyword2,...:Date[1|0]:css_class}

Then we can for example show a "Newsticker" for special keywords and we can use different css_classes in different situations/positions.

Another way for the Date-Parameter was to use the Format from the new {DATE:FORMAT} and if it is emty don't show a date :D .
Ralf
Locked