Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: I make new, what is wrong?
Plugin Composer — admin plugin to write your own plugins
Offline
Re: I make new, what is wrong?
Very nice the pair of you thanks.
If the images have been uploaded with TXP you can use the TXP image tag instead of “img src”. Just thought I’d mention that.
In the mean time, cuz I just like to mess around and try and learn something whilst I’m at it, I’ve changed the last line of code to:-
<code>return str_replace(array_keys($smilies), array_values($smilies), $GLOBALS[‘thiscomment’][‘message’]);</code>
<br />
and now it works in comments, but it doesn’t work in comment_preview mode so what is different about that? I presume I shall need to use if…else but what else is missing for the preview?
Last edited by thebombsite (2006-04-11 21:16:43)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: I make new, what is wrong?
Wow! Great plug-in! Thanks a lot! You’re my saver! “Just own personal Jesus Christ” © “The Matrix” =)
There are 10 types of people in the world – those who understand binary and those who don’t.
Offline
Re: I make new, what is wrong?
Btw, it would be great to make it work with excerpts…
$GLOBALS[‘WHAT-GOES-HERE?’][‘excerpt’]);
Last edited by [CPR]-AL.exe (2006-04-13 12:08:51)
There are 10 types of people in the world – those who understand binary and those who don’t.
Offline
Re: I make new, what is wrong?
$GLOBALS['thisarticle']['excerpt']
Plugin Composer — admin plugin to write your own plugins
Offline
Re: I make new, what is wrong?
thebombsite wrote:
and now it works in comments, but it doesn’t work in comment_preview mode so what is different about that? I presume I shall need to use if…else but what else is missing for the preview?
Hmmm… I’ve created a new function for comments and it works normally for displaying comments and previewing ‘em.
There are 10 types of people in the world – those who understand binary and those who don’t.
Offline
Re: I make new, what is wrong?
So… it looks like that now:
—————————
function cpr_smile_body()
{
// text to replace with html
$smilies = array(
‘=)’ => ‘<img src=“http://www.planetsmilies.com/smilies/happy/happy0163.gif” />’,
‘:-)’ => ‘<img src=“http://www.planetsmilies.com/smilies/happy/happy0146.gif” />’,
‘:-D’ => ‘<img src=“http://www.planetsmilies.com/smilies/happy/happy0148.gif” />’
);
return str_replace(array_keys($smilies), array_values($smilies), $GLOBALS[‘thisarticle’][‘body’]);
}
function cpr_smile_message()
{
// text to replace with html
$smilies = array(
‘=)’ => ‘<img src=“http://www.planetsmilies.com/smilies/happy/happy0163.gif” />’,
‘:-)’ => ‘<img src=“http://www.planetsmilies.com/smilies/happy/happy0146.gif” />’,
‘:-D’ => ‘<img src=“http://www.planetsmilies.com/smilies/happy/happy0148.gif” />’
);
return str_replace(array_keys($smilies), array_values($smilies), $GLOBALS[‘thiscomment’][‘message’]);
}
function cpr_smile_excerpt()
{
// text to replace with html
$smilies = array(
‘=)’ => ‘<img src=“http://www.planetsmilies.com/smilies/happy/happy0163.gif” />’,
‘:-)’ => ‘<img src=“http://www.planetsmilies.com/smilies/happy/happy0146.gif” />’,
‘:-D’ => ‘<img src=“http://www.planetsmilies.com/smilies/happy/happy0148.gif” />’
);
return str_replace(array_keys($smilies), array_values($smilies), $GLOBALS[‘thisarticle’][‘excerpt’]);
}
—————————
I am not good at PHP…but is there a way to declare array emphhh… outside functions’ bodies? I mean, can i declare it only one time and then access it in functions’ bodies? I bet, there is =) But what is this way?..
There are 10 types of people in the world – those who understand binary and those who don’t.
Offline
Re: I make new, what is wrong?
BTW, I can’t turn BB code on =\ I’m using FireFox
There are 10 types of people in the world – those who understand binary and those who don’t.
Offline
#21 2006-04-13 14:07:12
- KurtRaschke
- Plugin Author
- Registered: 2004-05-16
- Posts: 275
Re: I make new, what is wrong?
This forum uses Textile for formatting. Please see the “Quick Help” link underneath the post form.
-Kurt
kurt@kurtraschke.com
Offline
Re: I make new, what is wrong?
I know, but there is an option to turn on BB code. It doesn’t work.
Press “Edit” and you’ll see it under input window.
Last edited by [CPR]-AL.exe (2006-04-13 14:40:54)
There are 10 types of people in the world – those who understand binary and those who don’t.
Offline
Re: I make new, what is wrong?
Ok. Here we go. That’s the code:
—-
// text to replace with html
$smilies = array( ‘=)’ => ‘<img src=“http://www.planetsmilies.com/smilies/happy/happy0163.gif” />’, ‘:-)’ => ‘<img src=“http://www.planetsmilies.com/smilies/happy/happy0146.gif” />’, ‘:-D’ => ‘<img src=“http://www.planetsmilies.com/smilies/happy/happy0148.gif” />’ );
function cpr_smile_body()
{
return str_replace(array_keys($smilies), array_values($smilies), $GLOBALS[‘thisarticle’][‘body’]);
}
—-
This returns an error:
tag_error <txp:cpr_smile_body/> -> Warning: array_keys() [function.array-keys]: The first argument should be an array on line 22
tag_error <txp:cpr_smile_body/> -> Warning: array_values() [function.array-values]: The argument should be an array on line 22
So… the functions don’t get the array… what should be changed?
Last edited by [CPR]-AL.exe (2006-04-13 14:45:13)
There are 10 types of people in the world – those who understand binary and those who don’t.
Offline
Re: I make new, what is wrong?
Emph… do textpattern plug-ins support global variables? What’s wrong? =(
There are 10 types of people in the world – those who understand binary and those who don’t.
Offline