1 ladyease Feb 16, 2008 17:17
3 ladyease Feb 16, 2008 20:50
¥åßßå, as always you are a great help here.
My knowledge is very limited... but I don't think I can use placeholders for this particular idea.... anyhoo
So do I understand this code... that if it sees get_permanent_url it will render and replace it with the the permalink by using the php code?
$params['data'] .= '<br />'.str_replace( '<?php $Item->get_permanent_url(); ?>', $params['Item']->get_permanent_url(), $this->Settings->get( 'html_block' ) );
so the html in the html block would be?
<a href="$item_get_permanent_url$">bar</a>
I must be doing something wrong... which isn't really surprising... cause I really have no idea what I am doing... LOL
4 yabba Feb 17, 2008 10:56
See if this helps clarify
html_block wrote:
'defaultvalue' => '
<!-- Paste from here... -->
example of some html for the permalink <a href="$permanent_url$">$title$</a>
<!-- ...to here -->
',
/**
* Event handler: Called when rendering item/post contents as HTML. (CACHED)
*/
function RenderItemAsHtml( & $params )
{
// I'm lazy and this is less typing in replace array ;)
$Item = $params['Item'];
// list of all placeholders
$search = array( '$permanent_url$', '$title$' );
// list of placeholder replacements, must be in the same order as search
$replace = array( $Item->get_permanent_url(), $Item->title );
// replace placeholders with their values
$params['data'] .= '<br />'.str_replace( $search, $replace, $this->Settings->get( 'html_block' ) );
return true;
}
¥
5 ladyease Feb 17, 2008 15:31
That looks fantastic... so it pains me to tell you that it didn't work, nothing is rendered, not even plain text. ... not sure why. where should I go from here?
thanx for your help....
6 yabba Feb 17, 2008 16:03
You can see it working here ( [url=http://dev.innervisions.org.uk/]Dev blog[/url] )
You can grab the actual code here ( [url=http://dev.innervisions.org.uk/plugins/_newplugin.plugin.php.txt]plugin.txt[/url] )
See if that works as you expect on your install
¥
7 ladyease Feb 17, 2008 16:52
did I mention I was a blonde too... that again is another great piece of coding ¥åßßå! Beautiful! I hope to get this plugin up and running soon! Thanks for your help!!
8 yabba Feb 17, 2008 23:59
The world needs far more blondes :D
¥
9 blueyed Feb 18, 2008 00:01
Please do
$Item = & $params['Item'];
instead of
$Item = $params['Item'];
The latter won't work in PHP4 and the first one is more explicit anyway (assigning by reference).
10 yabba Feb 18, 2008 00:18
Is that important if all we need is to get info from $Item, as opposed to changing any of $Item's data ?
¥
11 blueyed Feb 22, 2008 20:58
No, ¥åßßå, when you only get data it's not really important if it's a reference or a copy.
Sorry for the confusion.. ;)
or summat like that, but you're better off using place holders :
[html block]foo = <a href="$item_url$">bar</a>[/html block]
and then just replace $item_url$ ;)
¥