{AUTHOR} Replacement Tag Enhancement

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
Jérôme
Posts: 481
Joined: Tue 16. Mar 2004, 10:33
Location: Cologne, Germany
Contact:

{AUTHOR} Replacement Tag Enhancement

Post by Jérôme »

Code: Select all

############################################################################################
## MOD Title: {AUTHOR} Replacement Tag Enhancement
## MOD Author: Jerome < spam@jerome-gamez.de > (Jerome Gamez) http://jerome-gamez.de/
## MOD Description: Adds an additional attribute to the {AUTHOR}-Replacement Tag
## MOD Version: 1.0
##
## Installation Level: Easy
## Installation Time: 5 Minutes
##
## Files To Edit:  includes/inc_front/content.func.inc.php
##
###########################################################################################
## For Security Purposes, Please Check http://www.phpwcms.de/forum/viewtopic.php?t=1415
## for the latest version of this MOD. Downloading this MOD from other sites could cause 
## malicious code to enter into your phpwcms-installation. As such, phpwcms will not 
## offer support for MOD's not offered at: http://www.phpwcms.de/forum/
###########################################################################################
## Author Notes:
##
##   This enhancement enables you to prepend an additional conditional Text to the
##   {AUTHOR} Replacement Tag.
##
##   If the article has no author, the prepended text is not inserted into the content
##
##     Usage examples:
##
##        {AUTHOR}
##        => Jerome Gamez
##
##        {AUTHOR:Author:}
##        => Author:Jerome Gamez
##
##        {AUTHOR:Author: }
##        => Author: Jerome Gamez
##  
##        If the article has no author:
##        {AUTHOR:Author: }
##        => 							(which means: nothing ;)
##
###########################################################################################
## MOD History:
##
##   2004-04-05 - Version 1.0
##      * Initial Release
##
###########################################################################################
## Before Adding This MOD To Your phpwcms, You Should Back Up All Files Related To This MOD
###########################################################################################

#
#-----[ OPEN ]------------------------------------------
#

include/inc_func/content.func.inc.php


#
#-----[ FIND ]------------------------------------------
#

// AUTHOR replacement tag: by Magnar Stav Johanssen
if( ! (strpos($content["all"],'{AUTHOR}')===false)) {
	$content["all"] = str_replace('{AUTHOR}', $content["articles"][$aktion[1]]["article_username"], $content["all"]);
}



#
#-----[ REPLACE WITH ]------------------------------------------
# 

// AUTHOR replacement tag: by Magnar Stav Johanssen
/* original method
if( ! (strpos($content["all"],'{AUTHOR}')===false)) {
	$content["all"] = str_replace('{AUTHOR}', $content["articles"][$aktion[1]]["article_username"], $content["all"]);
}
*/

if( ! (strpos($content["all"],'{AUTHOR')===false))
{	
	$content["all"] = str_replace('{AUTHOR}', $content["articles"][$aktion[1]]["article_username"], $content["all"]);
	if (empty($content["articles"][$aktion[1]]["article_username"]))
		$content["all"] = preg_replace('/\{AUTHOR:(.+?)\}/', $content["articles"][$aktion[1]]["article_username"] , $content["all"]);
	else
		$content["all"] = preg_replace('/\{AUTHOR:(.+?)\}/', "$1 ".$content["articles"][$aktion[1]]["article_username"] , $content["all"]);
}
This is the initial release, born out of a feature request.

I hope you can make use of it!

- Jérôme
Last edited by Jérôme on Tue 6. Apr 2004, 18:45, edited 1 time in total.
User avatar
sustia
Posts: 651
Joined: Fri 2. Apr 2004, 22:29
Location: Lecce (Italy)
Contact:

Post by sustia »

Hi Jérôme, thanks a lot for your efforts.

I have just tested in local your method, but seems doesn't works.

The problem is that, in a new category, I see the text "Autore" even if the category not contains articles, but in the article the name of the author is correctly displaced.
Jérôme
Posts: 481
Joined: Tue 16. Mar 2004, 10:33
Location: Cologne, Germany
Contact:

Post by Jérôme »

To be honest, Sustia... I don't understand what you mean.
Sustia wrote:in a new category, I see the text "Autore" even if the category not contains articles
Where do you see the text "Autore"? If the category does not contain articles, how can you see something on your website?
Sustia wrote:but in the article the name of the author is correctly displaced.
"correctly displaced" seems to be a contradiction to me. Anyway, I don't understand, what you mean :(.

Could you perhaps post a screenshot of what you mean that doesn't work? It could also be helpful if you show us how you have used the replacement tag and where.
snobba
Posts: 166
Joined: Sat 6. Mar 2004, 12:41
Location: Sweden
Contact:

Post by snobba »

Nice one Jeremo..I haven't tested it yet thought because I am in a designstage of a website..But I see all these new features added all the time and going to have a wonderful time when I finally put all the content online!

One question thought..What is the different in these two? I stared on it for a while but I can't figure it out.. :wink:

Code: Select all

##        {AUTHOR:Author:}
##        => Author:Jerome Gamez
##
##        {AUTHOR:Author: }
##        => Author: Jerome Gamez


Take care! By the way - take away the 'wannabe' before programmer in your profile!! You are a 'be'!

Martin
frold
Posts: 2151
Joined: Tue 25. Nov 2003, 22:42

Post by frold »

snobba wrote: One question thought..What is the different in these two? I stared on it for a while but I can't figure it out.. :wink:

Code: Select all

##        {AUTHOR:Author:}
##        => Author:Jerome Gamez
##
##        {AUTHOR:Author: }
##        => Author: Jerome Gamez
One single space after ":" :D
http://www.studmed.dk Portal for doctors and medical students in Denmark
Jérôme
Posts: 481
Joined: Tue 16. Mar 2004, 10:33
Location: Cologne, Germany
Contact:

Post by Jérôme »

frold is right. I just wanted to show that you can also use spaces for your prepended text, but you don't have to.

I also could have made it hardcoded that there is always a whitespace between the prepended text and the author name, but I thought this was a limitation.
snobba
Posts: 166
Joined: Sat 6. Mar 2004, 12:41
Location: Sweden
Contact:

Post by snobba »

AAAAA - now I see it!

8) with a stick = me!
User avatar
sustia
Posts: 651
Joined: Fri 2. Apr 2004, 22:29
Location: Lecce (Italy)
Contact:

Post by sustia »

It's ok Jérôme, now it works fine.

Sorry, I was wrong with the usage, putting {AUTOHR} instead of {AUTHOR} :oops:

Thanks a lot for your efforts and help :D
Jérôme
Posts: 481
Joined: Tue 16. Mar 2004, 10:33
Location: Cologne, Germany
Contact:

Post by Jérôme »

Okay, I am relieved that it works, so I can change my first post to something more positive :) Thank you for your report!
Post Reply