Page 1 of 1

{AUTHOR} Replacement Tag Enhancement

Posted: Mon 5. Apr 2004, 19:42
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

Posted: Tue 6. Apr 2004, 09:20
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.

Posted: Tue 6. Apr 2004, 11:40
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.

Posted: Tue 6. Apr 2004, 11:56
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

Posted: Tue 6. Apr 2004, 12:02
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

Posted: Tue 6. Apr 2004, 12:14
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.

Posted: Tue 6. Apr 2004, 12:49
by snobba
AAAAA - now I see it!

8) with a stick = me!

Posted: Tue 6. Apr 2004, 18:19
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

Posted: Tue 6. Apr 2004, 18:45
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!