The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Need help injecting code
Trying to do a str_replace in postbit_legacy and I'm not getting any results - Here's my code.
PHP Code:
Any ideas/suggestions? Thanks |
#2
|
||||
|
||||
Try this:
Code:
if ($vbulletin->options['legacypostbit']) { $find = trim(preg_replace('#^\$final_rendered = \'(.*)\';$#s', '\\1', compile_template('<vb:if condition="$post[\'postid\'] AND $post[\'threadid\'] AND !$show[\'moderated\']"> <a name="post{vb:raw post.postid}" href="{vb:link thread, {vb:raw thread}, {vb:raw pageinfo_post}}#post{vb:raw post.postid}" class="<vb:if condition="$show[\'inlinemod\']">ie</vb:if>postcounter">#{vb:raw post.postcount}</a><a id="postcount{vb:raw post.postid}" name="{vb:raw post.postcount}"></a> </vb:if>'))); $add = "testing..."; $vbulletin->templatecache['postbit_legacy'] = str_replace($find, $find . $add, $vbulletin->templatecache['postbit_legacy']); } |
#3
|
|||
|
|||
Thanks, but it didn't work for me.
Check out my attachment...what I've circled...between the post counter and the checkbox is where I want to inject that code. That is posbit_legacy, right? |
#4
|
||||
|
||||
Try running the code I gave you in the process_templates_complete hook.
|
#5
|
|||
|
|||
Thanks,
I tried that and got no love. |
#6
|
||||
|
||||
Okay, try this:
Code:
require_once(DIR . '/includes/adminfunctions_template.php'); $find = trim(preg_replace('#^\$final_rendered = \'(.*)\';$#s', '\\1', compile_template('<vb:if condition="$post[\'postid\'] AND $post[\'threadid\'] AND !$show[\'moderated\']"> <a name="post{vb:raw post.postid}" href="{vb:link thread, {vb:raw thread}, {vb:raw pageinfo_post}}#post{vb:raw post.postid}" class="<vb:if condition="$show[\'inlinemod\']">ie</vb:if>postcounter">#{vb:raw post.postcount}</a><a id="postcount{vb:raw post.postid}" name="{vb:raw post.postcount}"></a> </vb:if>'))); $replace = trim(preg_replace('#^\$final_rendered = \'(.*)\';$#s', '\\1', compile_template('<vb:if condition="$post[\'postid\'] AND $post[\'threadid\'] AND !$show[\'moderated\']"> <a name="post{vb:raw post.postid}" href="{vb:link thread, {vb:raw thread}, {vb:raw pageinfo_post}}#post{vb:raw post.postid}" class="<vb:if condition="$show[\'inlinemod\']">ie</vb:if>postcounter">#{vb:raw post.postcount}</a><a id="postcount{vb:raw post.postid}" name="{vb:raw post.postcount}"></a> </vb:if>testing...'))); $vbulletin->templatecache['postbit_legacy'] = str_replace($find, $replace, $vbulletin->templatecache['postbit_legacy']); |
#7
|
|||
|
|||
Still not showing up.
I echo'd out the variable $find to see what was going on and I get this: HTML Code:
if ($post['postid'] AND $post['threadid'] AND !$show['moderated']) { $final_rendered .= ' <a name="post' . $post['postid'] . '" href="' . vB_Template_Runtime::linkBuild("thread", $thread, $pageinfo_post) . '#post' . $post['postid'] . '" class="' . ''; if ($show['inlinemod']) { $final_rendered .= 'ie'; } else { $final_rendered .= ''; }$final_rendered .= '' . 'postcounter">#' . $post['postcount'] . '</a><a id="postcount' . $post['postid'] . '" name="' . $post['postcount'] . '"></a> '; } else { $final_rendered .= ''; }$final_rendered .= '' . ' |
#8
|
||||
|
||||
What I gave you should have worked.
What are you trying to add and where? Maybe getting the specifics will help. |
#9
|
|||
|
|||
I know - seems really strange that it isn't
Quote:
If you look up to a previous post where I added an attachment, you will see the Post number with the checkbox to the right of it (what's circled) Right in between the post # and the checkbox, I'm trying to add a hyperlink. The method I'm trying to use is to avoid going into the postbit_legacy template and manually adding it. By searching for a specific string, and then appending the hyperlink to that string would do the trick...at least, that's what I've learned from viewing other people's mods. Problem is I haven't found a similar mod that is 4.0 compatible...I see this technique used a lot in 3.x mods |
#10
|
||||
|
||||
Yes, the variables make it a little more difficult to do straight-forward string replaces now.
Let me ask you this... does the hyperlink need to go there or can you put it in a different spot? |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|