I want to add a new field in virtuemart new product form, how can i do that ?
I add:
var $is_act = 1;
in "components\com_virtuemart\tables\products.php"
And
<?php echo VmHTML::checkbox('is_act', $this->product->is_act); ?>
And in database but what is appear is a checkbox without a string behind it, what is the wrong ?!
The VMHTL::checkbox function just create a check box without strings.
If you want to add string behind it you have to do something like this.
<?php echo JText::_('COM_VIRTUEMART_PRODUCT_IS_ACT') ?>
<?php echo VmHTML::checkbox('is_act', $this->product->is_act); ?>
And then COM_VIRTUEMART_PRODUCT_IS_ACT should be added inside language file too.
for more clearness just check VM default product_edit_information.php page inside
administrator/components/com_virtuemart/views/product/tmpl/
Hope its helps..
Related
I have created custom fields for my registration/checkout form with Opencart 2.0. They show up on the admin section under each order, and I have successfully added them to the order_invoice.tpl, but I need to add them to the confirmation email that is sent to the customer. I think I have located the correct controller file: catalog>controller>account>order.tpl But I think the issue is that the code used to print it out in the order_invoice.tpl is referencing a folder or file in the admin side.
This is the code I am trying to execute in catalog>view>theme>yourtheme>template>mail>order.tpl
<?php foreach ($account_custom_fields as $custom_field) { ?>
<strong><?php echo $custom_field['name']; ?></strong>:
<?php echo $custom_field['value']; ?><br />
<?php } ?>
This is the error I get:
Notice: Undefined variable: account_custom_fields in
/home/raphaelseventworks.com/www/ncbaorders/catalog/view/theme/journal2/template/mail/order.tpl
on line 70Warning: Invalid argument supplied for foreach() in
/home/raphaelseventworks.com/www/ncbaorders/catalog/view/theme/journal2/template/mail/order.tpl
on line 70
Does anyone know how print out custom fields in the order confirmation email? Or what code I need to add to catalog>controller>account>order.tpl to make this work?
Thanks!
If i am correct you are trying to send additional values to confirmation email after checkout
you need to work on
catalog/model/checkout/order.php::addOrderHistory()
After order is placed, the order history is changed, here you can load your view file and pass custom values form controller according to your need.
Good Luck
I'm looking to move "Submitted By" info from node.tpl to page.tpl however when I add the following from node.tpl I get errors. Im assuming I dont have access to those variables, but would like to know how I can set up a pre-proccess to get it to display as it does in the node.tpl
<?php if ($display_submitted): ?>
<div class="submitted">
<?php print $submitted; ?>
</div>
<?php endif; ?>
You can either use a preprocess function in the template.php of your theme, as explained here:
https://drupal.stackexchange.com/questions/40222/how-can-i-print-node-authors-last-login-date-on-page-tpl-php
In your case it would look like this (tested on Drupal 7):
function yourtheme_preprocess_page(&$variables) {
$variables['author'] = "";
if (isset($variables['node']) && ($account = user_load($variables['node']->uid))) {
$variables['author'] = $account->name;
}
}
And then in your page.tpl.php use this:
Submitted by: <?php print $author; ?>
If you don’t want to touch any of your theme’s files, but you need to output the author’s name in another region as the node content, you could create a view (block display) containing the node author, and assign it to the region.
While normally done in node.tpl.php, if the page is a node view page, the $node variable is also available in page.tpl.php
You can then use something like:
if (isset($node)) {
// Check if display submitted variable is set for this node type
if (variable_get('node_submitted_'. $node->type, 0)) {
// Do stuff
}
}
An alternative approach would be adding the required logic instead to an implementation of
hook_preprocess_page
Bonus update: You can see the $node variable added to page.tpl.php in core template_preprocess_page
if ($node = menu_get_object()) {
$variables['node'] = $node;
}
In page.tpl.php:
<div class="submitted">
<?php echo format_date($node->created, 'custom','d.m.Y'); ?><br />
<?php echo 'by ' . $node->name; ?>
</div>
If I click on a product from my product overview on the left side, the shop does not load with the list.phtml. As soon as I swap view to grid or list, it swaps to the list.phtml file and everything is fine. But as I said, if I click on the products on the sidebar, it doesnt work (it's not even affected by list.phtml at all). I removed all the code inside it and it still showed (a bit different, that's why I want to change it) the products, but as soon as I swapped mode, everything disappeared -- as it should. Do you know where I can change that?
Thank you.
It should use list.phtml file. In that file it is defined for both list mode and grid mode.
<?php echo $this->getToolbarHtml() ?>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<?php $_iterator = 0; ?>
And
<?php else: ?>
<?php // Grid Mode ?>
<?php $_collectionSize = $_productCollection->count() ?>
You can see something like above code in your list.phtml file,one is for list mode and another for grid mode. This is the default case unless you haven't changed the layout or template code.
If you want to know the file location than you can always enable template path hint. If you don't know how to do that you can follow this.
After knowing from which file it is rendering you can fix it.
Hope this will help.
Does anyone know how to, without purchasing an addon/extension, add php code to the product and category descriptions? If you try to add it automatically gets commented out when you save, e.g. <!-- <?php echo "test" ?> -->
Workaround: For anyone else.. I used borderless iframe to include an external .php file which contained the php code I needed ....
All I'm trying to do is display a CCK field on custom--node.tpl.php but it seems everything has changed in D7 and there are no documentation on this.
In Drupal 6 I did it like so:
<?php print $node->field_myfield[0]['view'] ?>
In Drupa 7 I did it like so:
<?php print render($content['field_myfield']); ?>
The problem is that this field is html formatted and I really don't want that. How can I print/echo/display a CCK field on custom--node.tpl.php with my own formatting provided by my own CSS or template file?
If you don't want to actually render the content, you should be able to access the raw value of the field like this, depending on the type of field:
<?php print $node->field_myfield[$node->language][0]['value']; ?>
Get the formatted value of a cck field in Drupal 7:
<?php
$node = node_load($nid);
echo field_view_value('node', $node, 'field_YOUR_FIELD', node->field_YOUR_FIELD['und'][0]);
?>
Reference: http://plusfront.com/Drupal_6_Drupal_7_tip_Get_display_value_formatted_value_of_cck_fields