Actually, I have added one textarea in my opencart admin panel I fetch the textarea value to front end but it is not coming properly it coming HTML format, I fixed HTML format also but Pre tag is not working, Lines & showing paragraph only please help me how to resolve this,
admin product_form.tpl
<div class="form-group">
<label class="col-sm-2 control-label" for="input-desc<?php echo $language['language_id']; ?>">
<?php echo $entry_desc; ?>
</label>
<div class="col-sm-10">
<textarea name="product_description[<?php echo $language['language_id']; ?>][short_description]" placeholder="<?php echo $entry_desc; ?>" id="input-short_description<?php echo $language['language_id']; ?>" class="form-control summernote">
<?php echo isset($product_description[$language['language_id']]) ? $product_description[$language['language_id']]['short_description'] : ''; ?>
</textarea>
</div>
</div>
catelog product.tpl
<div class="short_description form-group" itemprop="description">
<h5 itemprop="name">Description:</h5>
<?php
$short_descriptions = strip_tags(html_entity_decode($short_descriptions, ENT_QUOTES, 'UTF-8'));
echo '<pre>';
print_r($short_descriptions);
echo '</pre>';
print_r($short_descriptions);
</div>
Related
I am using Opencart version 2.1.0.1. There is nothing changed in the contact form much. The contact form is sending the data in the GET method but it is supposed to send the data in POST method as the validations are being done for POST data.
Can someone please tell me what could be the issue. https://www.ijminc.com/index.php?route=information/contact is the website link for the contact page I am talking about.
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
// echo $this->request->post['is_redirect'];
if(empty($this->request->post['is_redirect'])){
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
$mail->smtp_username = $this->config->get('config_mail_smtp_username');
$mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
$mail->smtp_port = $this->config->get('config_mail_smtp_port');
$mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->request->post['email']);
$mail->setSender(html_entity_decode($this->request->post['name'], ENT_QUOTES, 'UTF-8'));
$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));
$mail->setText($this->request->post['enquiry']);
$mail->send();
$this->response->redirect($this->url->link('information/contact/success'));
}
In contact.tpl, the form code is as
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" class="form-horizontal">
<fieldset>
<legend><?php echo $text_contact; ?></legend>
<div class="form-group required">
<label class="col-sm-2 control-label" for="input-name"><?php echo $entry_name; ?></label>
<div class="col-sm-10">
<input type="text" name="name" value="<?php echo $name; ?>" id="input-name" class="form-control" />
<?php if ($error_name) { ?>
<div class="text-danger"><?php echo $error_name; ?></div>
<?php } ?>
</div>
</div>
<div class="form-group required">
<label class="col-sm-2 control-label" for="input-email"><?php echo $entry_email; ?></label>
<div class="col-sm-10">
<input type="text" name="email" value="<?php echo $email; ?>" id="input-email" class="form-control" />
<?php if ($error_email) { ?>
<div class="text-danger"><?php echo $error_email; ?></div>
<?php } ?>
</div>
</div>
<div class="form-group required">
<label class="col-sm-2 control-label" for="input-enquiry"><?php echo $entry_enquiry; ?></label>
<div class="col-sm-10">
<textarea name="enquiry" rows="10" id="input-enquiry" class="form-control"><?php echo $enquiry; ?></textarea>
<?php if ($error_enquiry) { ?>
<div class="text-danger"><?php echo $error_enquiry; ?></div>
<?php } ?>
</div>
</div>
<?php echo $captcha; ?>
</fieldset>
<div class="buttons">
<div class="pull-right">
<input class="btn btn-primary" type="submit" value="<?php echo $button_submit; ?>" />
</div>
</div>
</form>
Note : I have been working on this issue for 2 days now and did a lot of google search. I couldn't get any relevant answer that could solve my problem. If you guys have any link that could solve my issue, please post it.
Thanks for the help in advance.
I'm trying to create a custom template for my phpmaker project, I tried every possible solution to change the default CSS for labels but I cannot get input: focus selects input when it gets focus and Selector input: not(: focus): valid select input if valid input did not focus. Please suggest some ways to solve this issue
<div id="r_tennam" class="col-sm">
<div class="floating-group">
<label id="elh_tender_tennam" for="x_tennam" class="col-sm col-form-label ew-label"><?php echo $tender_add->tennam->caption() ?><?php echo $tender_add->tennam->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
<div <?php echo $tender_add->tennam->cellAttributes() ?>>
<span id="el_tender_tennam">
<input type="text" data-table="tender" data-field="x_tennam" name="x_tennam" id="x_tennam" maxlength="200" placeholder=" " value="<?php echo $tender_add->tennam->EditValue ?>"<?php echo $tender_add->tennam->editAttributes() ?>>
</span>
</div>
</div>
</div>
I need to call some php vars inside a html module on opencart, but when i use <?php ?> my page renders as <!--?php ?-->.
is there a way of doing this using the default HTML module of opencart 2.x
UPDATED
<!--?php ?--> this comment caused by CKEDITOR. But even without editor PHP will not run in standard OpenCart on client side. Here is a recipe howto deal with custom PHP in HTML module.
Adding extra field in OpenCart HTML module with PHP support.
admin/view/template/extension/module/html.tpl, find
<div class="form-group">
<label class="col-sm-2 control-label" for="input-description<?php echo $language['language_id']; ?>"><?php echo $entry_description; ?></label>
<div class="col-sm-10">
<textarea name="module_description[<?php echo $language['language_id']; ?>][description]" placeholder="<?php echo $entry_description; ?>" id="input-description<?php echo $language['language_id']; ?>" data-lang="<?php echo $lang; ?>" class="form-control summernote"><?php echo isset($module_description[$language['language_id']]['description']) ? $module_description[$language['language_id']]['description'] : ''; ?></textarea>
</div>
</div>
Add after
<div class="form-group">
<label class="col-sm-2 control-label" for="input-description2<?php echo $language['language_id']; ?>"><?php echo $entry_description; ?> 2</label>
<div class="col-sm-10">
<textarea name="module_description[<?php echo $language['language_id']; ?>][description2]" placeholder="<?php echo $entry_description; ?> 2" id="input-description2<?php echo $language['language_id']; ?>" data-lang="<?php echo $lang; ?>" class="form-control" style="min-height: 400px;"><?php echo isset($module_description[$language['language_id']]['description2']) ? $module_description[$language['language_id']]['description2'] : ''; ?></textarea>
</div>
</div>
This will be field for the second description.
catalog/controller/extension/module/html.php, find
$data['html'] = html_entity_decode($setting['module_description'][$this->config->get('config_language_id')]['description'], ENT_QUOTES, 'UTF-8');
Add after
$data['html2'] = html_entity_decode($setting['module_description'][$this->config->get('config_language_id')]['description2'], ENT_QUOTES, 'UTF-8');
if (preg_match('|<\?php.+?\?>|isu', $data['html2'])) {
ob_start();
#eval('?>' . $data['html2']);
$data['html2'] = ob_get_contents();
ob_end_clean();
}
This will add a second field and with PHP render.
catalog/view/theme/default(or YOUR_THEME)/template/extentsion/module/html.tpl
Add at the end
<?php if($html2) { ?>
<?php echo $html2; ?>
<?php } ?>
Hi there,
I'm working on a project, but I'm a bit stuck. It's a logical question. I'll explain: We have a list of articles - Table: articles - saved in the database. However, we have collapse-able elements (let's call them accordeons now), which are based on the enabled languages (Table: languages). Now I'm tasked with saving every input for every "Accordeon" in the database, where content for the accordeons is stored in "article_language".
The accordeon
(It's contained in a WHILE-loop)
<div class="accord">
<div class="accordeon-head" data-id="<?php echo $language['shortname']; ?>"><?php echo $language['fullname']; ?><div class="accordeon-right"><i class='fa fa-chevron-down'></i></div></div>
<div class="accordeon-body" data-id="<?php echo $language['shortname']; ?>">
<div class="form-container bottom">
<div class="form-float full-width">
<label class="input-label" for="agg_e_txt"><?php echo $lang['ARTS_INPL_TXT']; ?></label>
<textarea type="text" id="agg_e_txt" name="agg_e_txt"><?php echo $text['article_text']; ?></textarea>
</div>
<div class="clear toplabel"></div>
<div class="form-float middle">
<label class="input-label" for="agg_e_rec"><?php echo $lang['ARTS_INPL_RECUSE']; ?></label>
<textarea type="text" id="agg_e_rec" name="agg_e_rec"><?php echo $text['article_recuse']; ?></textarea>
</div>
<div class="space"></div>
<div class="form-float middle" style="float:right;">
<label class="input-label" for="agg_e_spec"><?php echo $lang['ARTS_INPL_SPEC']; ?></label>
<textarea type="text" id="agg_e_spec" name="agg_e_spec"><?php echo $text['article_spec']; ?></textarea>
</div>
</div>
<div class="clear"></div>
</div>
</div>
I'd like to do this with an AJAX post. What is the best way to store everything for an accordeon in the article_language table with the correct language prefix?
My thoughts were a WHILE loop in the AJAX call, or a each in the jQuery. But, I'm not sure.
What is the best way to achieve this?
I have a form which is posted via php and if I get a error it highlights only the input field red. What I would like to do or know if there is a way to do is highlight the whole div field which contains the select field and everything and show that this whole div has a error.
Here is my html code.
<div class="form-group">
<div class="<?php if(form_error('fullname')!= null){echo ' has-error';} ?>">
<label class="col-md-4 control-label">
<?php echo lang("full_name"); ?>
</label>
<div class="col-md-8">
<input type="text" name="fullname" class="form-control" value="<?php if (isset($userinfo['Fullname'])) {echo $userinfo['Fullname'];} ?>" placeholder="<?php echo lang(" fullname "); ?>">
</div>
</div>
</div>
Right now it only highlights input field but I want it to highlight the whole div form-group.
Since you are using bootstrap, you could try this. Please change
<div class="form-group">
to
<div class="form-group alert alert-danger">
Try this.
<div class="form-group <?php if(form_error('fullname')!= null){echo ' bg-danger';} ?>">
<div class="<?php if(form_error('fullname')!= null){echo ' has-error';} ?>">
<label class="col-md-4 control-label">
<?php echo lang("full_name"); ?>
</label>
<div class="col-md-8">
<input type="text" name="fullname" class="form-control" value="<?php if (isset($userinfo['Fullname'])) {echo $userinfo['Fullname'];} ?>" placeholder="<?php echo lang(" fullname "); ?>">
</div>
</div>
</div>
What I have done is used, .bg-danger, one of the Bootstrap Contextual Classes based on the same if condition you have to apply the has-error class.