Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 07-24-2010, 01:00 AM
NathanLedet NathanLedet is offline
 
Join Date: Nov 2005
Posts: 85
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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:
    if ($vbulletin->options['legacypostbit']) 
    { 
        
$find 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']);     
    } 
What it's supposed to be doing is looking for the post number, and then adding my variable onto it.

Any ideas/suggestions?

Thanks
Reply With Quote
  #2  
Old 07-24-2010, 01:50 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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']);      
    }
Reply With Quote
  #3  
Old 07-24-2010, 01:57 AM
NathanLedet NathanLedet is offline
 
Join Date: Nov 2005
Posts: 85
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Attached Images
File Type: png Screen shot 2010-07-23 at 9.53.01 PM.png (30.9 KB, 0 views)
Reply With Quote
  #4  
Old 07-24-2010, 02:31 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try running the code I gave you in the process_templates_complete hook.
Reply With Quote
  #5  
Old 07-27-2010, 05:17 PM
NathanLedet NathanLedet is offline
 
Join Date: Nov 2005
Posts: 85
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks,

I tried that and got no love.
Reply With Quote
  #6  
Old 07-27-2010, 05:30 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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']);
Reply With Quote
  #7  
Old 07-27-2010, 07:14 PM
NathanLedet NathanLedet is offline
 
Join Date: Nov 2005
Posts: 85
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 .= '' . '
Reply With Quote
  #8  
Old 07-27-2010, 07:30 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What I gave you should have worked.

What are you trying to add and where? Maybe getting the specifics will help.
Reply With Quote
  #9  
Old 07-27-2010, 07:46 PM
NathanLedet NathanLedet is offline
 
Join Date: Nov 2005
Posts: 85
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Boofo View Post
What I gave you should have worked.
I know - seems really strange that it isn't

Quote:
What are you trying to add and where? Maybe getting the specifics will help.
Thanks.

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
Reply With Quote
  #10  
Old 07-27-2010, 08:07 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:40 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04838 seconds
  • Memory Usage 2,283KB
  • Queries Executed 14 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_html
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete