Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-02-2009, 06:16 PM
Taragon's Avatar
Taragon Taragon is offline
 
Join Date: Sep 2007
Location: The Netherlands
Posts: 390
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Creating a product

When creating a product, what would be the best way to add a line of code to an existing template?

Currently I'd like to add
Code:
<script type="text/javascript" src="clientscript/jquery/1.3/jquery-1.3.2.min.js"></script>
to the headerinclude template like this
Code:
<meta http-equiv="Content-Type" content="text/html; charset=$stylevar[charset]" />
<meta name="generator" content="vBulletin $vboptions[templateversion]" />
<if condition="$show['threadinfo']">
<meta name="keywords" content="<if condition="$threadinfo['taglist']">$threadinfo[taglist], </if>$threadinfo[prefix_plain_html] $threadinfo[title], $vboptions[keywords]" />
<meta name="description" content="<if condition="$pagenumber>1"><phrase 1="$pagenumber">$vbphrase[page_x]</phrase>-</if>$threadinfo[prefix_plain_html] $threadinfo[title] $foruminfo[title_clean]" />
<else /><if condition="$show['foruminfo']">
<meta name="keywords" content="$foruminfo[title_clean], $vboptions[keywords]" />
<meta name="description" content="<if condition="$pagenumber>1"><phrase 1="$pagenumber">$vbphrase[page_x]</phrase>-</if>$foruminfo[description_clean]" />
<else />
<meta name="keywords" content="$vboptions[keywords]" />
<meta name="description" content="$vboptions[description]" />
</if></if>

<!-- CSS Stylesheet -->
$style[css]
<if condition="is_browser('opera') AND !is_browser('opera', '8.0.1')">
<style type="text/css" id="vbulletin_opera8fix_css">
ul, ol { padding-$stylevar[left]:20px; }
</style>
</if>
<if condition="$show['editor_css']">
$editor_css
</if>
<!-- / CSS Stylesheet -->

<script type="text/javascript" src="$stylevar[yuipath]/yahoo-dom-event/yahoo-dom-event.js?v=$vboptions[simpleversion]"></script>
<script type="text/javascript" src="$stylevar[yuipath]/connection/connection-min.js?v=$vboptions[simpleversion]"></script>
<script type="text/javascript">
<!--
var SESSIONURL = "$session[sessionurl_js]";
var SECURITYTOKEN = "$bbuserinfo[securitytoken]";
var IMGDIR_MISC = "$stylevar[imgdir_misc]";
var vb_disable_ajax = parseInt("$vboptions[disable_ajax]", 10);
// -->
</script>
<script type="text/javascript" src="clientscript/vbulletin_global.js?v=$vboptions[simpleversion]"></script>
<if condition="$show['popups']"><script type="text/javascript" src="clientscript/vbulletin_menu.js?v=$vboptions[simpleversion]"></script></if>

<script type="text/javascript" src="clientscript/jquery/1.3/jquery-1.3.2.min.js"></script>

<if condition="$vboptions['externalrss']">
	<link rel="alternate" type="application/rss+xml" title="$vboptions[bbtitle] RSS Feed" href="external.php?type=RSS2" />
	<if condition="$show['foruminfo'] OR $show['threadinfo']">
		<link rel="alternate" type="application/rss+xml" title="$vboptions[bbtitle] - $foruminfo[title_clean] - RSS Feed" href="external.php?type=RSS2&amp;forumids=$foruminfo[forumid]" />
	</if>
</if>
--------------- Added [DATE]1249243141[/DATE] at [TIME]1249243141[/TIME] ---------------

this doesn't seem to work
Code:
	<plugins>
		<plugin active="1" executionorder="5">
			<title>test</title>
			<hookname>global_start</hookname>
			<phpcode><![CDATA[$find = '<if condition="$show['popups']"><script type="text/javascript" src="clientscript/vbulletin_menu.js?v=$vboptions[simpleversion]"></script></if>';
$replace = '<if condition="$show['popups']"><script type="text/javascript" src="clientscript/vbulletin_menu.js?v=$vboptions[simpleversion]"></script></if>

<script type="text/javascript" src="clientscript/jquery/1.3/jquery-1.3.2.min.js"></script>';
$vbulletin->templatecache['headinclude'] = str_replace($find, $replace, $vbulletin->templatecache['headinclude']);]]></phpcode>
		</plugin>
	</plugins>
--------------- Added [DATE]1249245641[/DATE] at [TIME]1249245641[/TIME] ---------------

got it
Code:
$search = '<!-- / CSS Stylesheet -->';
$replace = '<!-- / CSS Stylesheet --> test123';
$vbulletin->templatecache['headinclude'] = str_replace($search, $replace, $vbulletin->templatecache['headinclude']);
Reply With Quote
  #2  
Old 08-02-2009, 10:16 PM
Taragon's Avatar
Taragon Taragon is offline
 
Join Date: Sep 2007
Location: The Netherlands
Posts: 390
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

'k, guess I'm still stuck

PHP Code:
$search addslashes('<!-- / CSS Stylesheet -->');
$replace addslashes('<!-- / CSS Stylesheet --> test 125345');

$vbulletin->templatecache['headinclude'] = str_replace($search$replace.$search$vbulletin->templatecache['headinclude']); 
is working, but
PHP Code:
$search addslashes('<!-- / CSS Stylesheet -->');
$replace $vbulletin->templatecache['vbdock_facebox_headinclude'];

$vbulletin->templatecache['headinclude'] = str_replace($search$replace.$search$vbulletin->templatecache['headinclude']); 
isn't.

Most likely just a typo, but any help would be more than appreciated!
Attached Files
File Type: zip product-vbdock_facebox.zip (834 Bytes, 2 views)
Reply With Quote
  #3  
Old 08-02-2009, 10:49 PM
1Unreal 1Unreal is offline
 
Join Date: Jul 2008
Location: London
Posts: 372
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why are you using addslashes?
Reply With Quote
  #4  
Old 08-02-2009, 10:54 PM
Taragon's Avatar
Taragon Taragon is offline
 
Join Date: Sep 2007
Location: The Netherlands
Posts: 390
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not really sure.. It was by the book, sort of say. But you're right, according to this http://us3.php.net/manual/en/function.addslashes.php it wouldn't be needed.

It doesn't alter the result though.
Reply With Quote
  #5  
Old 08-02-2009, 11:04 PM
1Unreal 1Unreal is offline
 
Join Date: Jul 2008
Location: London
Posts: 372
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I did this and it worked fine

PHP Code:
$search addslashes('<!-- / CSS Stylesheet -->');
$replace 'foo';

$vbulletin->templatecache['headinclude'] = str_replace($search$replace.$search$vbulletin->templatecache['headinclude']); 
Also, how are you checking it? It wont actually edit the template. So you wont see it in the template manager. However if you view the source it will be apparent.

It has to be on global_start too. Although Im sure you have already realised that
Reply With Quote
  #6  
Old 08-02-2009, 11:09 PM
Taragon's Avatar
Taragon Taragon is offline
 
Join Date: Sep 2007
Location: The Netherlands
Posts: 390
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

both [minicode]foo[/minicode] and [minicode]<!-- / CSS Stylesheet --> test 125345[/minicode] are indeed working. As it is right now you should be able to see the word foo on top of your website.

Since the code I'm using instead of foo is a bit longer, I'm trying to load a custom template called vbdock_facebox_headinclude. Which also is the thing that isn't working.
Reply With Quote
  #7  
Old 08-02-2009, 11:14 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can't you append it to the end of $headerinclude? Something like:
PHP Code:
$headerinclude =. $headerinclude '
<script type="text/javascript" src="clientscript/jquery/1.3/jquery-1.3.2.min.js"></script>'

Reply With Quote
  #8  
Old 08-02-2009, 11:15 PM
1Unreal 1Unreal is offline
 
Join Date: Jul 2008
Location: London
Posts: 372
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This should work (fetch_template())

PHP Code:
$search addslashes('<!-- / CSS Stylesheet -->');
$replace fetch_template(
$vbulletin->templatecache['vbdock_facebox_headinclude']);

$vbulletin->templatecache['headinclude'] = str_replace($search$replace.$search$vbulletin->templatecache['headinclude']); 
Reply With Quote
  #9  
Old 08-02-2009, 11:18 PM
Taragon's Avatar
Taragon Taragon is offline
 
Join Date: Sep 2007
Location: The Netherlands
Posts: 390
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Can't you append it to the end of $headerinclude? Something like:
PHP Code:
$headerinclude =. $headerinclude '
<script type="text/javascript" src="clientscript/jquery/1.3/jquery-1.3.2.min.js"></script>'

Interesting, I didn't think of that.
Quote:
Originally Posted by 1Unreal View Post
This should work (fetch_template())

PHP Code:
$search addslashes('<!-- / CSS Stylesheet -->');
$replace fetch_template(
$vbulletin->templatecache['vbdock_facebox_headinclude']);

$vbulletin->templatecache['headinclude'] = str_replace($search$replace.$search$vbulletin->templatecache['headinclude']); 
like a charm (:
Reply With Quote
Reply


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 04:18 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.04511 seconds
  • Memory Usage 2,295KB
  • Queries Executed 12 (?)
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
  • (4)bbcode_code
  • (7)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (1)postbit_attachment
  • (9)postbit_onlinestatus
  • (9)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_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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete