VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: rage76 on February 15, 2014, 09:49:07 AM

Title: how to override view.html.php file?
Post by: rage76 on February 15, 2014, 09:49:07 AM
hi, I am looking for a way to override view.html.php so that the "continue shopping" link can be altered to take the customer to the site homepage. Is there a way to do this without a core hack?

This is URGENT. Please help !!

VM ver 2.0.24a
Joomla ver 2.5.18
Title: Re: how to override view.html.php file?
Post by: jenkinhill on February 15, 2014, 19:06:16 PM
What has view.html.php to do with it? Did you not try a forum search? See http://forum.virtuemart.net/index.php?topic=122048
Title: Re: how to override view.html.php file?
Post by: rage76 on February 16, 2014, 15:46:46 PM
Sir,

I did read our post. You said,  It is in /components/com_virtuemart/views/cart/tmpl/default.php and is obviously labelled.

I found the below code in the file:

// Continue Shopping Button
         if (!empty($this->continue_link_html)) {
            echo $this->continue_link_html;

Are you suggesting:

echo $this->index.php ?

or should it be

echo index.php ?
------------------------------

On the other hand I found that "continue shopping" link on the checkout page was coming from view.html.php file !!

Please correct me and guide me.

regards
Title: Re: how to override view.html.php file?
Post by: Jazajay on February 17, 2014, 00:24:12 AM
Hi Rage76

In your templates folder create a html folder.

In their create another folder called [your components name you want to override]

Then in the component you want to override find the view folder and create that within the templates > html >  [your components name you want to override] folder.

So lets say you want to override a Virtuemart View in this case called padded.php, create the following:

templates/[template name]/html/[component name]/cart/padded.php

Now go to: components/com_virtuemart/views/cart/padded.php and copy this file to: templates/[template name]/html/[component name]/cart/padded.php

Now: templates/[template name]/html/com_virtuemart/cart/padded.php, will override: components/com_virteumart/views/cart/padded.php, regardless of a Virtuemart update (ie: you won't lose your changes on an update of virtuemart / nor will any updates get patched / loaded either).

Now in  their change: echo '<a class="continue" href="' . $this->continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>'; to:
echo '<a class="continue" href="[home page URL]" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';

Jaz
Title: Re: how to override view.html.php file?
Post by: rage76 on February 17, 2014, 07:23:51 AM
hi Jazajay

Thanks, but I have already done what you are suggesting. by doing this, "continue shopping" link on the facebox has changed, however, other similar links have not. I especially need to change the one which is shown on checkout page. After some research, I found that it is coming from view.html.php file.

Any ideas / suggestions are welcome !!

best wishes
Title: Re: how to override view.html.php file?
Post by: Jazajay on February 17, 2014, 07:31:43 AM
Hi Rage76
That is a seperate link.

You can find that here:


<div class="width50 floatleft right">
<?php // Continue Shopping Button
if (!empty($this->continue_link_html)) {
echo $this->continue_link_html;
?>

</div>


File:  com_virtuemart/views/cart/tmpl/default.php
Line: 94
Title: Re: how to override view.html.php file?
Post by: StefanSTS on February 17, 2014, 08:46:29 AM
Hi,

if you make a full text search over the virtuemart folders, you find the variable, that holds the link.

$continue_link = JRoute::_ ('index.php?option=com_virtuemart&view=category' . $categoryLink, FALSE);

Just use a text search tool like in Total Commander and find the files with $continue_link and change them according to your needs.

Found 5 files by the way.

So long
Stefan
Title: Re: how to override view.html.php file?
Post by: Jazajay on February 17, 2014, 09:04:04 AM
I have to admit I prefer stefen's solution to mine as it will save u time asking :)
Title: Re: how to override view.html.php file?
Post by: rage76 on February 17, 2014, 09:18:53 AM
Thanks Stefan & Jazajay

Will try and see how it goes !!
Title: Re: how to override view.html.php file?
Post by: rage76 on February 17, 2014, 16:23:08 PM
I too found 5 files with the said link.

Now the question is how do I override these files?

anyone done this? or do I have to do a core hack?
Title: Re: how to override view.html.php file?
Post by: AH on February 17, 2014, 17:22:32 PM
Core hack
Title: Re: how to override view.html.php file?
Post by: rage76 on February 18, 2014, 06:30:07 AM
Ok, I found and changed this link:
$continue_link = JRoute::_ ('index.php?option=com_virtuemart&view=category' . $categoryLink, FALSE);

to

$continue_link = JRoute::_ ('index.php' . $categoryLink, FALSE);

but it is not working. did I do anything wrong?
Title: Re: how to override view.html.php file?
Post by: Jazajay on February 18, 2014, 09:27:25 AM
I would say it's not the right file you changed :)
Title: Re: how to override view.html.php file?
Post by: StefanSTS on February 24, 2014, 18:23:16 PM
Quote from: rage76 on February 18, 2014, 06:30:07 AM
$continue_link = JRoute::_ ('index.php' . $categoryLink, FALSE);
but it is not working. did I do anything wrong?

Did you change that only in one file or in all 5 files?

Title: Re: how to override view.html.php file?
Post by: Milbo on February 26, 2014, 17:07:03 PM
You dont need todo a core hack. Just dont use the prepared value. Just ignore $continue_link and set your own link. use vmdebug('my this',$this); to see what you can use in your template
Title: Re: how to override view.html.php file?
Post by: rage76 on February 26, 2014, 17:37:57 PM
Dear Milbo

You will have to explain this in a better way. I am sorry but I didn't understand !!
Title: Re: how to override view.html.php file?
Post by: AH on February 26, 2014, 20:13:13 PM
He asked to override the continue link, not creat his own link  :)

If he had asked to remove the link and create his own link then I would have suggested another option  8)
Title: Re: how to override view.html.php file?
Post by: Milbo on February 27, 2014, 15:19:24 PM
Why he wants to override the continue link? and not just directly use the one he creates anyway?
Title: Re: how to override view.html.php file?
Post by: StefanSTS on February 28, 2014, 18:07:23 PM
Quote from: rage76 on February 18, 2014, 06:30:07 AM
$continue_link = JRoute::_ ('index.php?option=com_virtuemart&view=category' . $categoryLink, FALSE);
to
$continue_link = JRoute::_ ('index.php' . $categoryLink, FALSE);
but it is not working. did I do anything wrong?

I just saw, that you are still appending the $categoryLink:
$continue_link = JRoute::_ ('index.php', FALSE);
might do the trick.

There is kind of a documentation for JRoute: http://docs.joomla.org/API17:JRoute, but I didn't really dig deaper to find out how JRoute really works and if you need it.
Well, this solution is kind of the fast lane, probably dirty in programmers eyes, but I am not a programmer. ;-)

So long
Stefan