Vote View

  • Posts: 197
  • Thank you received: 13
8 months 2 days ago #355898

-- HikaShop version -- : 5.0.0
-- Joomla version -- : 4.3.4
-- PHP version -- : 8.1

in hikashop view files, vote and comment form is located in show.php file

is there possibility to put the vote code in a partial view (like "show_block_img.php" or "show_block_tags.php") so thatt i can put the comment section wherever i want regarding to the project UI design ?

Please Log in or Create an account to join the conversation.

  • Posts: 81853
  • Thank you received: 13143
  • MODERATOR
8 months 2 days ago #355902

Hi,

Yes and no. If you configured the "Choose which module you want to enable" setting of the HikaShop configuration to "Vote & Comment connected", the vote and comment have to be submitted by the user in the same form, which forces you to have them in the same area. That's why we have them in the same view.
Actually, if you want to display the vote elsewhere on the product page, and supposing that you set the "Choose which module you want to enable" setting to "vote only" or "vote & comment", then, a vote only area is displayed by default on the right side of the product page, with the code:

<!-- VOTE -->
		<div id="hikashop_product_vote_mini" class="hikashop_product_vote_mini"><?php
	if($this->params->get('show_vote_product')) {
		$js = '';
		$this->params->set('vote_type', 'product');
		$this->params->set('vote_ref_id', isset($this->element->main) ? (int)$this->element->main->product_id : (int)$this->element->product_id );
		echo hikashop_getLayout('vote', 'mini', $this->params, $js);
	}
		?></div>
<!-- EO VOTE -->
As you can see, it uses the vote / mini.php view file as it only contains the vote form.
And this can be moved anywhere in the show_default product page layout view file with the drag & drop editor.

The following user(s) said Thank You: khashiz

Please Log in or Create an account to join the conversation.

  • Posts: 197
  • Thank you received: 13
8 months 2 days ago #355917

by your explanations i get how to place "vote" anywhere i want.
but how about the comment form ?

how i can change the display place of comment form ?

Please Log in or Create an account to join the conversation.

  • Posts: 81853
  • Thank you received: 13143
  • MODERATOR
8 months 1 day ago #355921

Hi,

That's complex.
The comment form is inside its own form. And the product layout (show_default for example) is also inside its own form.
And in HTML you can't have a form inside a form.
So if you edit the view file product / show.php, you can see the code to display the product page layout near the top with the code:

	<form action="<?php echo hikashop_completeLink('product&task=updatecart'); ?>" method="post" name="hikashop_product_form" onsubmit="return hikashop_product_form_check();" enctype="multipart/form-data">
<?php

$this->variant_name ='';
if(!empty($this->element->variants) && $this->config->get('variant_increase_perf', 1) && !empty($this->element->main)) {
	foreach(get_object_vars($this->element->main) as $name => $value) {
		if(!is_array($name) && !is_object($name)) {
			if(empty($this->element->$name)) {
				if($name == 'product_quantity' && $this->element->$name == 0) {
					continue;
				}
				$this->element->$name = $this->element->main->$name;
				continue;
			}
		}
		if($this->params->get('characteristic_display') == 'list' && !empty($this->element->characteristics) && !empty($this->element->main->characteristics)) {
			$this->element->$name = $this->element->main->$name;
		}
	}
}

$this->setLayout($this->productlayout);
echo $this->loadTemplate();

if($this->productlayout != 'show_tabular') {
?>
		<input type="hidden" name="cart_type" id="type" value="cart"/>
		<input type="hidden" name="add" value="<?php echo !$this->config->get('synchronized_add_to_cart', 0); ?>"/>
		<input type="hidden" name="ctrl" value="product"/>
		<input type="hidden" name="task" value="updatecart"/>
		<input type="hidden" name="return_url" value="<?php echo urlencode(base64_encode(urldecode($this->redirect_url))); ?>"/>
	</form>

and a bit below, you have the code to display the comment form:
[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>
Moving the comment form inside product_default is complex since you would end up with a form inside a form and you need to avoid that one way or another.
For example, for the show_tabular view file, we moved the form of the product page layout inside the layout excluding the bottom part of the layout so that the comment form could be in the tabs of the layout.

The following user(s) said Thank You: khashiz

Please Log in or Create an account to join the conversation.

Time to create page: 0.060 seconds
Powered by Kunena Forum