VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: balai on November 21, 2011, 12:52:47 PM

Title: [solved] JPagination does not let extend VM
Post by: balai on November 21, 2011, 12:52:47 PM
Hi

I have tried to extend some VM models in a custom component and to use the category VM layout for the products display.

I m noticing one problem with the pagination.
It is always redirecting me to the VM pages.

I think that it could be solved easily, if the pagination's form action which is now a static URI, will be defined as a variable  in the category view class.

What you think?
Title: Re: JPagination does not let extend VM
Post by: balai on November 22, 2011, 16:39:57 PM
Any thought on that?
Title: Re: JPagination does not let extend VM
Post by: Milbo on November 23, 2011, 13:23:27 PM
I think we should take a look on it. You may help us and provide us with your suggested fix
Title: Re: JPagination does not let extend VM
Post by: balai on November 24, 2011, 10:11:34 AM
Ok np

line 172 of the file components\com_virtuemart\views\category\tmpl\default.php

<form action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$this->category->virtuemart_category_id ); ?>" method="post">

Could be transformed to
<form action="<?php echo $this->paginationAction;?>" method="post">

Then you have to define that var to the category view class: components\com_virtuemart\views\category\view.html.php


//set this after the $categoryId definition
$paginationAction=JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$categoryId );
$this->assignRef('paginationAction', $paginationAction);




Generally i would suggest you not to use static URIs in the layouts. Better to define them elsewhere and use a varriable.
This way if you want to add a new variable to the URI's query its easy without having all the users change their layouts.
Also the layouts could be used by other extensions

Title: Re: JPagination does not let extend VM
Post by: balai on December 22, 2011, 13:12:10 PM
Hi Max

I m checking the new version.

that the var paginationAction is passed in the template through  the view class but not its not used there.
The pagination form's action is still a static URL. Also the get method is blocking queries to be passed as actions.

Is there any chance those 2 minor changes (action and method) to be done ?

file: components\com_virtuemart\views\category\tmpl\default.php (line 149)
Title: Re: JPagination does not let extend VM
Post by: Studio 42 on December 23, 2011, 09:58:36 AM
Hi,
I changed to "get" to past variable in uri because the value in this form are reused to generate the pagination/orderby ... and on using "post" we can't past value form plugin search extention.
If you want to do a template with posting the values, you can, but sure this are not working as expected.
If you wan't modify a "GET" value you can use getVar and SetVar , modify it in a joomla plugin or in a javascript.

What is the interest to use "POST" and changing the

//set this after the $categoryId definition
$paginationAction=JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$categoryId );
$this->assignRef('paginationAction', $paginationAction);


The interess can be to change the option=com_virtuemart to

$option = jRequest::getvar('option','com_virtuemart');
and changing line
<form action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$this->category->virtuemart_category_id ); ?>" method="get">
to
<form action="<?php echo JRoute::_('index.php?option='.$option.'&view=category&virtuemart_category_id='.$this->category->virtuemart_category_id ); ?>" method="get">
Title: Re: JPagination does not let extend VM
Post by: balai on December 23, 2011, 18:18:22 PM
Hi Electrocity

Thank you.

I though that the layout could be used also by other extensions to display products not only from a selected category but maybe grouped using other criteria.