Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 02-16-2008, 07:55 AM
lordtopcat lordtopcat is offline
 
Join Date: Oct 2004
Location: New Zealand
Posts: 152
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Find in template

Hi Guys,

I am just starting out with php programming...

What code do I need to find a bit of template code and replace it with something else in vB? I am trying to make a product where it finds xx template code, and replaces it with yy.

I have been trying ever so hard, but I can't quite get it.

Cheers
LTC
Reply With Quote
  #2  
Old 02-16-2008, 08:31 AM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Maybe this: [How-To] Using Plugins for Automatic Template Edits ?
Reply With Quote
  #3  
Old 02-16-2008, 04:18 PM
cheesegrits's Avatar
cheesegrits cheesegrits is offline
 
Join Date: May 2006
Posts: 500
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Opserty - If he's just starting, the plugin method for template changes is probably a littler deep! Even experienced vB coders have problems with that.

TC - The first issue is finding the right template you need to modify. You can't generally just search for text using the ACP template search, because pretty much none of the text you see on the actual page is in the template, as it's all dynamically included with phrases and runtime variables.

So the first thing to do is enable the "Add Template Name in HTML Comments" option in the ACP, under vBulletin General Options. This will embed comments in each page showing where every template stops and starts. So you can view source of the page you are working on, and see what part of the page is in which template.

Then you can start looking at the template you need in the ACP template editor. If you are running in debug mode, you will have access to the Master Style. DO NOT EDIT ANYTHING IN THE MASTER STYLE! Use the Default style, or create a test style.

I can pretty much guarrantee your first look at some template code will confuse the heck out of you. Don't Panic. It's all pretty straight forward. It's usually obvious what each $vhphase[] is about, and if not you can look it up in the Phrase Manager. So it's usually pretty simple working out where you need to make your edits.

When you do make an edit, I suggest you get in the habit of wrapping comments around stuff you change, like ...

<!-- start edit - changed this to do whatever -->
... the template code ...
<!-- end edit -->

If you always use the same words, like "start edit", it makes it a lot easier to find your edits in the future, which comes in real handy when you upgrade vB.

-- hugh
Reply With Quote
  #4  
Old 02-16-2008, 07:14 PM
lordtopcat lordtopcat is offline
 
Join Date: Oct 2004
Location: New Zealand
Posts: 152
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh yes, thank you for that Cheese. I actually know how to edit templates etc...But what I am trying to do is create my first product. I want to find XX piece of code, and replace it with YY piece of code when someone installs the product. Any suggestions ?
Reply With Quote
  #5  
Old 02-16-2008, 08:29 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If it involves customising a default vBulletin template it is best just to provide instructions to the User as to what to do. Most people will already have other mods installed and customised styles (especially if they are downloading mods), if you start messing around with their styles automatically then they are going to get annoyed when their vBulletin falls apart.

Just provide instructions to modify existing templates and if you are making new templates insert them into the MASTER STYLE and associate the template's product with your product.
Reply With Quote
  #6  
Old 02-16-2008, 09:12 PM
cheesegrits's Avatar
cheesegrits cheesegrits is offline
 
Join Date: May 2006
Posts: 500
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Or better yet use the Advanced Product Manager, which makes the basic steps of creating a product and adding templates, plugins, phrases, settings, etc. a snap. Works on 3.6 and 3.7.

Doesn't help with the vB template edits, but takes a lot of the pain out of everything else.

-- hugh
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 03:50 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.04323 seconds
  • Memory Usage 2,204KB
  • Queries Executed 13 (?)
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
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete