Is anyone can explain what is the difference between
payment_return.tpl(path ../bankwire/views/templates/hook/payment_return.tpl)
and
payment_execution.tpl (path ../bankwire/views/templates/front/payment_execution.tpl ) ?
Why in payment_execution.tpl I can see CART/ORDER variables(such as country name, order weight and other) in payment_return.tpl I сan't?
Thanks
These templates work with different "environment":
payment_execution.tpl assigned in /modules/bankwire/controllers/front/payment.php and have access to all template variables assigned in core files.
payment_return.tpl appears in hook and have access to limited list of variables. In file /modules/bankwire/bankwire.php method hookPaymentReturn($params) you may see it, there you have access to $params array and can assign to template any additional variables that you need.
Related
In SilverStripe 3.4.1 I want to control _config.php file values through the Admin settings. I want to set some variables in Admin > Settings > MyTab and then access these variables in _config.php.
Is there a way to access SiteConfig variables in the _config.php file?
I tried to use several different ways to get the config data:
Config::inst()
print_r/var_dump gives all the values as an array
Config::inst()->get($this->class, 'PropertyName') or $this->config()-> get('PropertyName')
Returns empty
SiteConfig::current_site_config() or any other similar variations based on the previous two
Internal Server Error
The reason I want to do this is I have a plugin that replaces some SilverStripe default action but it requires some data to be inserted. If this data is not inserted it should stay as default.
Here are some resources I have read through to try to find a solution:
http://api.silverstripe.org/3.3/class-Config.html
https://docs.silverstripe.org/en/3.0/topics/configuration/
https://docs.silverstripe.org/en/3.4/developer_guides/configuration/configuration/
https://docs.silverstripe.org/en/3.4/developer_guides/configuration/siteconfig/
The issue is DB::connect is not called at that stage in _config.php. Therefore we cannot retrieve items from the database.
What we can do is call DB::connect in our _config.php before we retrieve our SiteConfig.
Assuming our database config settings are stored in $databaseConfig, here is the code to fetch our SiteConfig:
DB::connect($databaseConfig);
$siteConfig = SiteConfig::current_site_config();
Then we can retrieve SiteConfig variables like so:
$siteConfig->Title;
I have spent hours searching to find where magento stores full county name.
We can get a full list of countries using this code:
$_countries = Mage::getResourceModel('directory/country_collection')
->loadData()
->toOptionArray(false);
This will return an array with country code and name, I investigated the directory module, and found out this call gets data from the table
directory_county
But this table don't have full county name! So where is it stored?
and how is it retrieved using that call?
Thanks in advance.
Ok so to compensate for my wrong answer. Here is how this works:
/lib/Zend/Locale/Data/en.xml - if your store is in english, else another xml in the same directoery is read. Every country is there and its code under the xml tag <territory>
The xml is cached using the Zend_Cache_Core class.
/lib/Zend/Locale.php - function getTranslation invokes the lib/Zend/Cache/Core.php class
to load from the cache.
Example: If you change the name of some country in en.xml and clear the magento cache. You will see the change when u invoke your code again.
Full country names are not stored in database. Magento uses inbuilt Zend functionality.
Check file: lib/Zend/Locale/Data/Translation.php for full list.
Use the Zend_Local translation.
<?php
$code = 'EN';
echo Mage::app()->getLocale()->getTranslation($code, 'Territory', null, 2);
?>
Use the column 'iso2_code' from the table 'directory_country' for your $code.
Magneto only stores country codes in DB, and relies for names on Zend's Locale module to provide translated names, for different locale.
By the toOptionArray method it invokes the Zend_Locale class to get the translated value.
Refer $name = Mage::app()->getLocale()->getCountryTranslation($data['value']);, which gets to Mage_Core_Model_Locale and then to Zend_Locale.
It decides which of the node from the data to read, by the switch case statement in Zend_Locale_Data::getContent() line# 962, 963
Magento caches the names, so if you make any change to XML files, make sure to clean your cache folder to get what you seek.
I'm building a CakePHP application, and I'm trying to allow users to pick an email template from a list and then send it to the addresses that they choose. I'd like to avoid hard-coding the names of the templates, as they are likely to change and be updated over time. How can I generate a list (in my controller) of the filenames of all the email templates I have? I've tried accessing the contents of app/view/Emails/text using the CakePHP Folder class as described here: http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html
However, that didn't work; I'm unable to get the contents of that directory. I just need to access the filenames; I can do the rest of the logic once I get them.
Try this in any method in your controller:
App::uses('Folder', 'Utility');
$dir = new Folder(APP . 'View/Emails/text/');
$files = $dir->find('.*\.ctp');
//print the array to inspect
pr($files);
It should show you all the .ctp template files in /app/View/Emails/text/
I have a wordpress blog. I created a db table which stores dictionary information and I want to publish this data from a URL . (For ex: "myblogaddress.com/mytest.php")
I have been researching for 2 days but nothing works I tried.
In my page; I use the php code shown in blow.
<?php
global $wpdb;
$words = $wpdb->get_results("SELECT * FROM $wpdb->words")
echo $words[0]->ENG;
?>
I wonder that;
- Which directory does my php page to be into ?
- What I need to do (other config, permission etc.) to do what I want.
Regards.
If you're loading it from a standalone PHP file (ie not from within your WordPress theme), you'll have to call wp-load.php to initialise the WordPress variables (including $wpdb). Have a look at this answer, including the comment about only needing wp-load.php.
I'd consider using a relative path (what that would be would depend on where you put your page relative to WordPress) rather than using $_SERVER['DOCUMENT_ROOT'];, but that's just a personal preference.
EDIT
Rereading after seeing your comment, I've just realised $wpdb->words probably won't exist. Try
$words = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "words")
instead. That'll generate the table name correctly as wp_words. Of course, you'll need to populate it the same way.
I have a file (js.phtml) where my code executes. I need to access some user data. When I error_log($this) in js.phtml, it displays, "Mage_Core_Block_Template" - which is confusing to me. I would expect that to be the parent class, not the value of the class getting passed to my .phtml file.
So, how do I supply the .phtml file with custom objects or methods? I'm super new to Magento and I've just been dropped into a task, so I apologize for possibly using incorrect terminology.
Edit:
My full file path is:
/app/design/frontend//default/template/customer/welcome/js.phtml
There is also a full module dir here:
/app/code/local//Customer/
Edit:
I need access to the users country and userid. It's ok if country is null.
Edit:
I've been doing additional research, it looks like I can do something like this:
Current user in Magento?
But I haven't tried it in code yet ....
Edit: Figured it out:
error_log(print_r(Mage::getSingleton('customer/session')->getCustomer()->getEntityId(), true));
error_log(print_r(Mage::getSingleton('customer/session')->getCustomer()->getCountry(), true));
To get customer ID:
echo Mage::getSingleton('customer/session')->getCustomer()->getId();
To get country - depends from which address. Here's an example of getting the country code from the default billing address:
echo Mage::getSingleton('customer/session')->getCustomer()->getDefaultBillingAddress()->getCountry();
I am somewhat new to Magento, but I think this should work.
$customer = Mage::getSingleton('customer/session')->getCustomer();
That gets the customer object. Then...
echo $customer->getAddresses();
That should get the country somewhere in the address. As for userid...I don't see it on the documentation page..You could try
echo $customer->getAttributes();
And see what is in there. The documentation page is at:
http://docs.magentocommerce.com/Mage_Customer/Mage_Customer_Model_Customer.html