Opencart 3.0. Doesn't change colomn_left in admin panel - opencart

I try to change my admin panel and add new column to left column
enter image description here
I change file admin/controller/common/left_column.php
if ($this->user->hasPermission('access', 'customer/cards')) {
$customer[] = array(
'name' => $this->language->get('text_customer_card'),
'href' => $this->url->link('customer/cards', 'user_token=' . $this->session->data['user_token'], true),
'children' => array()
);
}
I clean browser and opencart cache. But nothing changes!
What to do? Help me, please.

I just forgot to clear the mod cache. Thanks.

Related

Gravity forms repeater with upload file error

I'm building a form with a repeater and a file upload inside. When I submit the form, the input file filed always give me the error: There was an error while uploading the file. Error code: 1
Add
Here's my code:
$uploadfiles = GF_Fields::create( array(
'type' => 'fileupload',
'id' => 1006, // The Field ID must be unique on the form
'formId' => $form['id'],
'multipleFiles' => false,
'allowedExtensions' => 'gif,jpg,jpeg,png,txt,rtf,pdf,doc,docx,odt,ppt,pptx,odp,xls,xlsx,ods,xml',
'description' => '<br>Relevant documents: our transport way bill, probill, photos, etc.<br>Files must be less than 2 MB.<br>Allowed extensions: gif jpg jpeg png txt rtf pdf doc docx odt ppt pptx odp xls xlsx ods xml.',
'label' => __('Please attach any relevant document', 'srx'),
'pageNumber' => 1, // Ensure this is correct
));
// Create a repeater for the team members and add the name and email fields as the fields to display inside the repeater.
$team = GF_Fields::create( array(
'type' => 'repeater',
'description' => '',
'id' => 1000, // The Field ID must be unique on the form
'formId' => $form['id'],
'label' => __('Products', 'srx'),
'addButtonText' => __('Add product', 'srx'),
'removeButtonText' => __('Remove product', 'srx'),
'maxItems' => 100, // Optional
'pageNumber' => 1, // Ensure this is correct
'fields' => array( $reference, $quantity, $product, $lista, $uploadfiles ), // Add the fields here.
) );
Even tho the field is not required, it gives me the error anyways.
Another question I have is about the use of multipleFiles = true. This doesn't work at all. Any idea why ?
Thank you so much !
The Repeater API does not currently support File Upload fields. Here's a full list of known limitations:
https://docs.gravityforms.com/repeater-fields/#limitations
If you need repeating file uploads, check out Gravity Forms Nested Forms:
https://gravitywiz.com/documentation/gravity-forms-nested-forms/

How to use custom price table in open cart

The concept of our project is, area wise products filtering, the products may be same or different. If the admin change the price of the product for particular area, then the price should change only that corresponding area.
For that, we have created new table as like oc_product_to_category with following new fields price,quantity,offer.
if the new table has the price value means then use that value for the process, if else means use default price value at the oc_product table. Upto category page we have successfully implemented this concept,
Category.php:
$this->load->model('mobile/product');
$price_by_category = $this->model_mobile_product->getpricebycategory($result['product_id'],$category_id);
if($price_by_category['price'] != ""){
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
'price' => "Rs.".$price_by_category['price'].".00",
'special' => $special,
'tax' => $tax,
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
'rating' => $result['rating'],
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);;
}else{
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
'rating' => $result['rating'],
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);
}
At cart , it takes the default price table value. If I create new function means, i have to change whole cart operation but i only want to change the price calculation, Based on the area id and product id.
I hope someone will give the solution.
Thanks..
There's no need to repeat the entire block for category.php. You can simply re-assign the price before adding to the array like $price = $price_by_category['price'] ?: $price.
To load your model in cart.php you can do it like this. In the __contruct block add:
public function __construct($registry) {
$this->registry = $registry;
Then in the getProducts() method you can load your model:
$this->load->model('mobile/product');
$mobileProduct = $this->registry->get('model_mobile_product');
$price_by_category = $mobileProduct->getpricebycategory($product_id,$category_id);
Of course the challenge here is you will need to add category data to the cart array when customer adds product to cart so you will be able to reference this later. My suggestion would be to encode it as a third slice in the cart session. Normally products look like this:
product-id:serialized-option-data:profile-id
So you can add another slice to store category id when adding to cart:
product-id:serialized-option-data:profile-id:category_id
Then afterward:
if (!empty($product[3])) {
$category_id = $product[3];
} else {
$category_id = 0;
}
You will also need to send category_id as POST data to controller/checkout/cart -> add() and then again pass it to system/library/cart.php to be encoded into the cart array.

Displaying a custom twig template with Sonata and Symfony2

For my need, I'm planning to add a custom column to a entity list.
I've written this inside the configureListFields :
->add('_action', 'actions', array(
'actions' => array(
'code' => array('template' => 'BOBAdminBundle:test:custom.html.twig'),
)
))
My twig :
<img src="{{ asset('bundles/sonataadmin/famfamfam/delete.png') }}" />
It works.
Problem : I don't know why :S, since I've just copy/paste the code from somewhere.
I figured out than the '_action' determined the name of the column. But what if I want to change it ?
Where does this 'actions' name come from ? Where can I change it ?
The _action is used to add custom actions for the list items. Like edit and delete which are set by default. Here is a full documentation:
List actions
You can set actions for the list items by adding an ‘_action’ field in configureListFields:
<?php
$listMapper->add('_action', 'actions', array(
'actions' => array(
'view' => array(),
'edit' => array(),
)
))
Edit and delete actions are enabled in the default configuration. You can add your own! Default template file is: *SonataAdminBundle:CRUD:list_action[ACTION_NAME].html.twig*
You can specify your own by setting up the ‘template’ option like so:
<?php
$listMapper->add('_action', 'actions', array(
'actions' => array(
'view' => array(),
'edit' => array(),
'delete' => array('template' => 'MyBundle:MyController:my_partial.html.twig'),
)
))

Custom Prestashop Admin Module

I am developing a module for prestashop (basically, it's a very custom import of data and the only thing I need is to have a form and process data). I have created controller class derived from the ModuleAdminController but the problem is where should I put the tpl file containing the look of my custom form?
I realize that I can put tpl file to the templates but I want to keep all files within my module folder, is it possible (probably somewhere like "/views/templates/admin")?
This is the most easy method to create a basic admin controller / action in Prestashop 1.6
Create basic configuration :
./config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>foo</name>
<displayName><![CDATA[Foo]]></displayName>
<version><![CDATA[2.1.3]]></version>
<description><![CDATA[Bar.]]></description>
<author><![CDATA[your-name]]></author>
<tab><![CDATA[administration]]></tab>
<is_configurable>0</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>
./foo.php
if (!defined('_PS_VERSION_'))
exit;
class BarcodeEasyPrint extends Module
{
public function __construct()
{
$this->name = 'foo';
$this->tab = 'administration';
$this->version = '1.0.0';
$this->author = 'your-name-here';
$this->need_instance = 0;
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('Foo');
$this->description = $this->l('Bar.');
if ((int)Tools::getValue('p'))
$this->page = (int)Tools::getValue('p');
}
}
You need to create the controller with base functions :
./controllers/admin/AdminFooController.php
class AdminFooController extends ModuleAdminController {
public function __construct() {
$this->bootstrap = true;
parent::__construct();
}
public function createTemplate($tpl_name) {
if (file_exists($this->getTemplatePath() . $tpl_name) && $this->viewAccess())
return $this->context->smarty->createTemplate($this- >getTemplatePath() . $tpl_name, $this->context->smarty);
return parent::createTemplate($tpl_name);
}
public function initContent(){
parent::initContent();
$tpl = $this->createTemplate('content.tpl')->fetch();
/* DO STUFF HERE */
$posts = array();
$this->context->smarty->assign('posts', $posts);
}
}
You can use boostrap directly in the template file :
./views/templates/admin/content.tpl
<div class="row">
<div class="col-md-6">
</div>
<div class="col-md-6">
</div>
</div>
If it is an admin module only, then you will have no need to create any views. Because Prestashop provides a nice structure for admin section which is easy to use and we dont need to use any views or .tpl files. For admin section, normally three types of views or .tpl files are required, one for data display in grid, second for form and third for displaying a single record.
Prestashop already created .tpl files for them which you can find in "admin_folder/themes/default/templates". In our controllers for admin, for form and for data grid, we just create arrays and PS handles to view the form and data grid according to the arrays we created.
So if you need a custom form at admin, then create a public function renderForm and create the form array in it, like below:
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Video'),
'image' => '../img/admin/tab-genders.gif'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Video Title:'),
'name' => 'title',
'lang' => true,
'size' => 70,
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()##"�{}_$%:',
'required' => true
),
array(
'type' => 'textarea',
'label' => $this->l('Video Code'),
'name' => 'video_code',
'rows' => 5,
'cols' => 70,
'desc' => $this->l('Place the embed code for the video')
),
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'button'
)
);
return parent::renderForm();
} /* End of render member */
For other fields, checkout other prestashop admin controllers and you will see that how easily we can create forms in PS using that simple definitions in the arrays and we dont need to create .tpl files.
For front end, we can use the new modules MVC structure, where our module folder have sub folders for controllers (controllers/front, controllers/admin) , views and models .
Hope this will help you.
Thank you
You need to use the helper form, here is the documentation for it, it is really easy to use ;) .
http://doc.prestashop.com/display/PS15/HelperForm
You also can find more information about how and where to use helper form, look for the function getContent() and displayForm().
http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module
unfortunately any document not exist to point directly to solve this question but hear i have some URLs really useful and you should combine theme and get your realize:
http://presthemes.com/prestashop-news/modules-classes-and-controller-override-by-julien-breux-4.html
http://doc.prestashop.com/display/PS15/Diving+into+PrestaShop+Core+development
http://doc.prestashop.com/display/PS15/New+Developers+Features+In+PrestaShop+1.5
http://blog.belvg.com/how-to-implement-a-controller.html
best regards
extending the answer from #altafhussain create a folder views/templates/admin in your module and place your customview.tpl
Than append the free text block as below.
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Legend')
),
'input' => array(
array(
'type' => 'free',
'label' => 'Whatever label text',
'desc' => $this->display(__FILE__,'views/templates/admin/customview.tpl'),
'name' => 'FREE_TEXT',
'required' => false
)
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'button'
)
);
return parent::renderForm();
}

Facebook PHP SDK 3.0 - How to get my page wall posts at any time?

I have been trying to read the news feed from a page that I have using an app that I'm coding.
Now I have had some issues trying to do this using the PHP SDK 3.0.
I am able to get the page information, but this is something that is publicly available any way.
My question is how do I get (read) the page wall posts? I'm assuming I have to grant permissions to my app to post to page, but how do I do this?
currently this is the code that I have
$appId = 'XXXXXXXXXXXXXXXXXX';
$secret = 'YYYYYYYYYYYYYYYY';
$pageId = 'ZZZZZZZZZZZZZZZZZZ';
$facebook = new Facebook(array(
'appId' => $appId,
'secret' => $secret
));
$pageProfile = $facebook->api($pageId);
$pagePosts = $facebook->api($pageId . '/posts/');
echo 'My Page profile';
print_r($pageProfile);
echo 'My Page wall';
print_r($userPosts);
Under 'My Page wall' I don't get anything. I don't get any errors either.
To access the posts of a page, it is /feed and not /post. Then, here is the correct version of your example :
require "facebook.php";
$facebook = new Facebook(array(
'appId' => YOUR_APP_ID,
'secret' => YOUR_APP_SECRET,
));
$pageFeed = $facebook->api(THE_PAGE_ID . '/feed');
Then the array $pageFeed will contain the 25 latest posts and links to navigation :
Array(
[data] => Array(
[0] => Array(
[id] => ...
[from] => ...
[to] => ...
[message] => ...
[icon] => ...
[type] => ...
[application] => ...
[created_time] => ...
[updated_time] => ...
)
[1] => ...
[2] => ...
...
[24] => ...
)
[paging] => Array(
[previous] => https://...
[next] => https://...
)
)
Hope that helps !
I know this is old, but I'll bring it up again! I just spent the last three days busting tail and trying to hack and crack the PHP SDK and Graph API, and I've done alright! I posted a full length lab with code and descriptions on my page, and you can view it below and ask me any questions you might have.
Basically, page feed is in a "graph" of info, or a super array. You use the app to connect to the facebook page, and get the feed. Connecting to a page's feed requires no permission from the page, hence why all you need is your APP ID, APP SECRET, and PAGE ID. The SDK automatically generates the APP ACCESS TOKEN for you, so you'r good there.
From then on, it's just about manipulating the graph. I've learned that Facebook feed has different types of posts. some are "photo", "message", "link". Anyways, check out the lab and tell me what you think.
http://www.callmenick.com/labs/displaying-a-custom-facebook-page-feed