- Posts: 17
- Thank you received: 1
Display vote form in custom component
9 years 9 months ago #256962
by ddasios
Display vote form in custom component was created by ddasios
-- HikaShop version -- : 2.6.4
-- Joomla version -- : 3.6.4
Hello.
I have a custom component that display a hikashop product.
I want below it to display the whole vote ranking and comment form, with the product id as a parameter.
Could guide me to do this?
Thanks
-- Joomla version -- : 3.6.4
Hello.
I have a custom component that display a hikashop product.
I want below it to display the whole vote ranking and comment form, with the product id as a parameter.
Could guide me to do this?
Thanks
Please Log in or Create an account to join the conversation.
9 years 9 months ago #257003
by nicolas
Replied by nicolas on topic Display vote form in custom component
Hi,
First, you need to initialize HikaShop if that's not already the case with such code:
Then, you can base yourself on the code we use in the "show" file of the "product" view in order to display the vote system at the bottom of the product page:
First, you need to initialize HikaShop if that's not already the case with such code:
Code:
include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_hikashop'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php');
Then, you can base yourself on the code we use in the "show" file of the "product" view in order to display the vote system at the bottom of the product page:
Code:
<form action="<?php echo hikashop_currentURL() ?>" method="post" name="adminForm_hikashop_comment_form" id="hikashop_comment_form">
<div id="hikashop_vote_listing" data-votetype="product" class="hikashop_product_vote_listing">
<?php
if($this->params->get('show_vote_product')) {
//LAYOUT listing of the comments for this product
$js = '';
if(isset($this->element->main)) {
$product_id = $this->element->main->product_id;
} else {
$product_id = $this->element->product_id;
}
$this->params->set('product_id',$product_id);
echo hikashop_getLayout('vote', 'listing', $this->params, $js);
?>
</div>
<div id="hikashop_vote_form" data-votetype="product" class="hikashop_product_vote_form">
<?php
//LAYOUT form to send a comment & vote
$js = '';
if(isset($this->element->main)) {
$product_id = $this->element->main->product_id;
} else {
$product_id = $this->element->product_id;
}
$this->params->set('product_id',$product_id);
echo hikashop_getLayout('vote', 'form', $this->params, $js);
}
?>
</div>
<input type="hidden" name="add" value="1"/>
<input type="hidden" name="ctrl" value="product"/>
<input type="hidden" name="task" value="show"/>
<input type="hidden" name="return_url" value="<?php echo urlencode(base64_encode(urldecode($this->redirect_url))); ?>"/>
</form>
Please Log in or Create an account to join the conversation.
9 years 9 months ago #257033
by ddasios
Replied by ddasios on topic Display vote form in custom component
Thank you Nicolas for the information. I have managed to do this as you proposed with some changes on $this element
Please Log in or Create an account to join the conversation.
Time to create page: 0.146 seconds