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

Reply
 
Thread Tools Display Modes
  #1  
Old 05-20-2012, 07:44 AM
Syxguns's Avatar
Syxguns Syxguns is offline
 
Join Date: Jul 2011
Posts: 280
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default HTML image change in Template

I'm not that strong of a coder and so I need a little help. This is going to be two questions, so I'm going to first start with the image change. What is different about the image change on this is that I can not make the changes in the BBCode Manager, I have to make the changes in the individual templates for each code.

First original code:
Code:
Customize Template: vbpcsi_add_to_cart_link

<div>
	<a href="{vb:raw url}">
		{vb:rawphrase vbpcsi_add_to_cart}
	</a>
</div>
If I follow the basic instructions given to me adding an image would look like this:

Code:
<div>
	<a href="{vb:raw url}"> <img src="http://www.address.to.image
		"alt="{vb:rawphrase vbpcsi_add_to_cart, {vb:raw url}}"title="
                  {vb:rawphrase vbpcsi_add_to_cart, {vb:raw url}}" / >
	</a>
</div>
At least I think this is what is suppose to be the best way for the image instead of text to show, and for SEO. Please correct this if it is wrong, I'm a beginner here!!

The first question is making the image change. When you select the button it will be added to your shopping cart. I would like a new button that says, "Thank You!" to take the place of the, "Add To Cart" button.

The second question, remember that I'm new so I may need a little more in depth instruction than most, is I need to create additional codes that are based off the current codes, but will have different buttons. A little better example:

Product button to go to the store where the item is located is created and I have a template to modify. Using basically the same template, but I need to create a new one that will have a different button on it than, "View Item". How do I make a fresh template for that?

I hope one of you coders can help me out, I will really appreciate it!
Reply With Quote
  #2  
Old 05-20-2012, 02:05 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think what you want to do is make the image src a template variable, like this:

Code:
<div>
	<a href="{vb:raw url}"> <img src="{vb:raw img_url}"
		alt="{vb:rawphrase vbpcsi_add_to_cart, {vb:raw url}}"title="
                  {vb:rawphrase vbpcsi_add_to_cart, {vb:raw url}}" / >
	</a>
</div>
Then your code would set that to the correct url depending on the product and/or whether or not it's already in the cart.
Reply With Quote
  #3  
Old 05-20-2012, 08:09 PM
Syxguns's Avatar
Syxguns Syxguns is offline
 
Join Date: Jul 2011
Posts: 280
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

kh99,
I appreciate the answer but it is not clear enough for my full understanding. Let me give you a little more detail.

Add to Cart BBCode from Code Manager
Code:
Title: Add To Cart
BB Code Tag Name: ADDCART
Replacement:  <a href="{param}">ADDCART</a>
Example: [ADDCART]B00078MG5M[/ADDCART]
Add to Cart Template
Code:
Customize Template: vbpcsi_add_to_cart_link

<div>
	<a href="{vb:raw url}">
		{vb:rawphrase vbpcsi_add_to_cart}
	</a>
</div>

With this current code, I can add a link to an item in my vB forum, and after you select it with a mouse click it will redirect you back to the thread that you are on, but if you select the checkout image or products page, then all items you selected will be there. My images are just little png files that I create to take the place of a hyperlink by using the BBCode. However, when I used the BBCode Manager to create the links to the "hyperlink images", it messed up. They told me that if I wanted to add images it would need to be from the template design. I would show you how it works, but my site is still under development. You can as a guest at least see the store integration, but as a guest you will not be able to view links. Check it out here: http://www.place4musicians.com

P.S. If you see the Koi in the cart, that was from me setting up an example for someone I was going to do the design for.
Reply With Quote
  #4  
Old 05-20-2012, 08:17 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm...well, I can see what they mean. There really isn't any way to do what you want in the bbcode. You could do it in the template, but you'd have to find the php code that handles the template then make changes there. If the template is named vbpcsi_add_to_cart_link then somewhere there must be code that looks some thing like:

Code:
$template = vB_template::create('vbpcsi_add_to_cart_link');
$template->register('url', $url); 
$something = $template->render();

and you'd have to add code to figure out what image you want and call $template->register() to add it to the template (and also add the vb:raw tag like I mentioned before).
Reply With Quote
  #5  
Old 05-20-2012, 09:46 PM
Syxguns's Avatar
Syxguns Syxguns is offline
 
Join Date: Jul 2011
Posts: 280
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just for a rough variation of the question, is there a way to use an "if" statement to call on the second image after click of the mouse within the original template document? If I use the correct commands and have two different <img src= locations could I get it to work that way?
Reply With Quote
  #6  
Old 05-21-2012, 10:56 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It depends on how the cart system works. You could use some javascript to change the image when it's clicked, but then the server won't know the item's in the cart until it gets told somehow. But you could use an "ajax" call to do that (it's a pretty common thing to do, but a little more complicated).
Reply With Quote
  #7  
Old 05-21-2012, 05:31 PM
Syxguns's Avatar
Syxguns Syxguns is offline
 
Join Date: Jul 2011
Posts: 280
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Right now the "Add to Cart" is set up on a redirect to bring the user back to the vB thread they are on, so I'm taking a shot in the dark and thinking that changing the button my not be possible or if it is possible, that the change may not be worth the effort.

thanks kh99
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 01:34 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.06113 seconds
  • Memory Usage 2,221KB
  • Queries Executed 11 (?)
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
  • (6)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete