Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
Re: I make new, what is wrong?
global $smilies has to be declared outside function as well.
Plugin Composer — admin plugin to write your own plugins
Offline
Re: I make new, what is wrong?
But in the code, that I’ve posted it’s declared outside the function… could you show me the exact way to do that, please?..
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?
Just declare it at the very beginning of your code, then declare it within the function too. I mean global
BTW, you should be careful about doing such things as declaring a global variable not to make a conflict in textpattern, and perhaps it is better to avoid doing so in a general case.
EDIT: update the plugin, I’ve shown how that should be done (without globals).
Last edited by Inspired (2006-04-14 21:00:17)
Plugin Composer — admin plugin to write your own plugins
Offline
Re: I make new, what is wrong?
Oh, that’s a nice one =) Thank you so much! ;)
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?
I know, that I’m too insolent, but is there a way to create a plugin, that will render the text like this:
< txp:render_smileys > text =))) bla-bla =) < /txp:render_smileys >
It could be very useful in some cases… ;)
Last edited by [CPR]-AL.exe (2006-04-19 19:10:07)
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?
I have a question: how do I embed the smileys on the article? I have the plugin and it works great. one thing though — they don’t show up in feeds. in other words, when you click “preview” in the Write Tab, it’s shown in text as in :smiley:, not an image… I’m into feedfetchers and my readers are in it too.. but when the feeds are fetched, the smileys just wont show up.. is there any code to alter this? how come wordpress can do that? can txp do that too?o_0
Offline