News:

Looking for documentation? Take a look on our wiki

Main Menu

add a view to productdetails page

Started by Pirosoft, May 11, 2012, 13:57:04 PM

Previous topic - Next topic

Pirosoft

hi! i want add a view to productdetails page, i have a table with other info (extra virtuemart), i created a model for this table and placed on /administrator/components/com_virtuemart/models/vmextra.php after i have created a view and placed in components/com_virtuemart/views/productdetails/default_extra.php and changed components/com_virtuemart/views/productdetails/view.html.php adding in display function the rows:
//load extra
$vmextra_model = VmModel::getModel('vmextra');
$vmextra = $vmextra_model->get('Item');
$this->assignRef('vmextra', $vmextra);    

and in default.php added:
echo $this->loadTemplate('vmextra');

but non show the info! why? can you help me?

thanks



PRO

echo $this->loadTemplate('vmextra');

use    INCLUDE


Pirosoft

in my default_extra.php i have:
<?php
defined('_JEXEC') or die('Restricted access');
echo "<br>test<br>";
//here my code
echo "<br>";
?>

i see <br>test<br>
but not the code for extra info from database... i must add controller or other?

PRO

Pirosoft,

please explain what you want to do with your view etc.

MORE than likely, you are going about this the wrong way

Pirosoft

simply i have a table called
jos_virtuemart_extra with id, product_id, id_extrainfo and a other table
jos_extrainfo with id_extrainfo, textextrainfo
and i make a select in my model



class VirtueMartModelVmextra extends VmModel {

function __construct() {
parent::__construct();
}

function getItem ($id = null){
$product_id = JRequest::getInt('virtuemart_product_id');
$db = JFactory::getDBO();
$query->select('v.id as vid, v.product_id, v.id_extrainfo, p.id_extrainfo, p.textextrainfo');
$query->from('#__virtuemart_extra AS v');
$query->join('LEFT', '#__extrainfo AS p ON v.product_id = p.id_extrainfo');
$query->where(" v.product_id = '{$product_id}'");
$db->setQuery($query);

$result = $db->loadObject();
return $result;
     
}
}


and i want show this info in my productdetails view.
I have explained it better? :)

PRO

what is the info?

you should be using a plugin


Pirosoft

are info stored with a my component, and i want show this info in productdetails page.  This info are linked with product_id, so i want create a view.

PRO

Quote from: Pirosoft on May 11, 2012, 15:14:52 PM
are info stored with a my component, and i want show this info in productdetails page.  This info are linked with product_id, so i want create a view.

Just the standard custom field  can do quite a lot,
http://forum.virtuemart.net/index.php?topic=99225.0
give me an example of the data stored?


BUT, a customfield plugin can query the database.



and you do not need a "view" if you want the fields to be displayed on the product page

Pirosoft

table #__virtuemart_extra
id - product_id - id_extrainfo

table #__extrainfo
id_extrainfo -  textextrainfo

i make a join on id_extrainfo where product_id is the id in URL "virtuemart_product_id"

Pirosoft

so i create a plugin like this
http://dev.virtuemart.net/projects/virtuemart/wiki/Product_Plugins

and after i use customfields? Can you tell me the parameters of customfields?

PRO

what is the extra info?

Can you not use a string? or product spec plugin?


Pirosoft

extrainfo is the table with info from another component. textextrainfo is a text, and i must use this. but are you sure that i can't use another view? why in my test VirtueMartModelVmextra don't give back the info?

PRO

Quote from: Pirosoft on May 11, 2012, 20:02:02 PM
extrainfo is the table with info from another component. textextrainfo is a text, and i must use this. but are you sure that i can't use another view? why in my test VirtueMartModelVmextra don't give back the info?

Ok 1st, vmart team does not support core hacks, thats what you are doing.

What you want can easily be done with custom fields,

WHAT type of data do you have stored?

Give me an example

Pirosoft

table #__virtuemart_extra
id - product_id - id_extrainfo

table #__extrainfo
id_extrainfo -  textextrainfo

join and
id      product_id   -   id_extrainfo  -    textextrainfo
1             2                       1                information text
2             3                       2                second information text

i want select this info and cerate link to my component
<a href="index.php?option=com_mycomponent&view=extra&product_id=1">information text</a>
second example
<a href="index.php?option=com_mycomponent&view=extra&product_id=3">second information text</a>