In html.tpl.php I have written :
<?php if($front_page):?>
<?php print 'Google+ '?>
<?php endif; ?>
but its not working moreover its hanging the home page.
Can someone please tell me the correct syntax if it has some error
Should you not be using echo instead of print?
<?php if(drupal_is_front_page()):
echo 'Google+';
endif; ?>
In most themes, you should be overriding page.tpl.php rather than html.tpl.php. You also have a couple of errors in your syntax. The typical code for a template would read:
<?php if($front_page): ?>
Google+
<?php endif; ?>
Note the space in the first line, plus you don't need to print the second.
Related
I'm trying to customize the html print order (url http://www.yoursite.com/index.php/sales/order/print/order_id/8/ ) but I can't find the right file to do this.
I'm working on template/sales/order/print files but all the changes I made aren't visible.
could you please give me a hint?
Thanks a lot
Best regards
EDIT: ok, I've found the file that I need to modify, it is print-phtml in app/design/frontend/default/MYTEMPLATE/template/sales/order
Now I'd like to add product description in each row in this html print page, but I don't know how I can do this
There is
<?php $_items = $_order->getItemsCollection(); ?>
<?php $_count = $_items->count(); ?>
<?php foreach ($_items as $_item): ?>
<?php if ($_item->getParentItem()) continue; ?>
<tbody>
<?php echo $this->getItemHtml($_item) ?>
</tbody>
<?php endforeach; ?>
so I think that I have to modify something in $this->getItemHtml($_item) but I have no idea where is this getItemHtml
could you please help me? thanks a lot
The file you have to edit is the \sales\order\items\renderer\default.phtml , but changes you make here will also appear on the order view page.
To avoid this, you can use the following condition in this phtml (there is also an example in the original version):
<?php if ($this->getPrintStatus()): ?>
....
<?php endif;?>
.. and for similar issues in the future: on the admin panel, in System/Configuration menu if you switch to "Store view", you will find an option under Advanced/Developer tab called "Template path hints". If you set it to "yes", you will see the template pathes in the frontend, embedded inline next to each block. How to use template path hints
Why vew helper duplicates the menu displays, though I give him a different set of data. Twice menu 'navigation1' is displayed
<?php echo $this->navigation('navigation1')->menu() ?>
<?php echo $this->navigation('navigation2')->menu() ?>
But the following code, individually, displays a different menu
<?php //echo $this->navigation('navigation1')->menu() ?>
<?php echo $this->navigation('navigation2')->menu() ?>
and
<?php echo $this->navigation('navigation1')->menu() ?>
<?php //echo $this->navigation('navigation2')->menu() ?>
Why is this happening and how can I avoid this? Thanks.
Can you post the factories and config arrays you are using to assemble the navigation? What you are showing should work fine so the issue lies in one of the other files but I would have to see them to help you.
I got this code below from a tutorial I'm using to learn PHP. I know that // is used to comment out code. In the first line of the code below, you see {// subject selected ?>
Is the php tag ?> not commented out by the // along with the subject selected text?
<?php if (!is_null($sel_subject)) {// subject selected ?>
<h2><?php echo $sel_subject['menu_name'];?></h2>
<?php } elseif (!is_null($sel_page)) {// page selected ?>
<h2><?php echo $sel_page['menu_name']; ?></h2>
<?php } else { // nothing selected ?>
<h2>Select a subject or page to edit</h2>
<?php } ?>
the BEST place to address such questions is an official man page:
The "one-line" comment styles only comment to the end of the line or the current block of PHP code, whichever comes first. This means that HTML code after // ... ?> or # ... ?> WILL be printed: ?> breaks out of PHP mode and returns to HTML mode, and // or # cannot influence that.
I can assure you that it's way more reliable source of knowledge than some volunteered help from some enthusiast
No, ?> is not commented out.
no ?> are not commented out with the in line comment, where as the block comment they are.
http://codepad.org/YUhG2DTd
Example: The following ?> does not get commented out.
<?php
\\?>
echo 'works';
?>
where as the following does get commented out.
<?php
/*
?>
*/
echo 'failed';
?>
{// subject selected ?>
No, the ?> is not commented. Because, that is not part of a php statement. That is a tag that apache uses to determine. Apache will send the contents enclosed by the tags to php and place the output from php in its output buffer.
Can someone explain to me when <?= needs to be used or why this programmer would code this way? I'm working on creating a third party module for SPBAS and I nearly figured it out, I just don't know the significance of the two different options I've specified.
Thanks in advance.
<?= functionhere(); ?> is a short hand for <?php echo functionhere(); ?>.
what <?=something?> is the short form of doing <?php echo something; ?>
where as <? something; ?> does whatever something was supposed to do
edit: im generalizing something as any php call, function string, array, object etc..
<?php functionhere(); ?> does not print out the results from the function, <?=functionhere(); ?> does.
This is a shortcut syntax to echo the variable that comes after it. It has the same effect as
<?php echo $variable; ?>
or
<?php echo functionhere(); ?>
in your case.
<?php functionhere(); ?>
will not do anything. unless something is printed out inside the function
For this to work, short_open_tag has to be enabled
<?= functionhere(); ?> = <?php echo functionhere(); ?>
<? functionhere(); ?> = <?php functionhere(); ?>
They are called short tags and can be enabled via the PHP configuration.
They do the same thing. Only difference is <?php is proper syntax.
One is short tag for echo - but it should not be used because if this function is turned off it will output your code. Thanks for the vote down.
So, why does this work:
<?php if (condition): ?>
<!--html code here-->
<?php endif; ?>
But not simply this:
<?php
if (condition) { ?>
<!--html code here-->
<?
}
I figured it was just style preference, but I actually can't seem to get it to work the second way. Am I just doing something completely wrong? I can't see the purpose of outputting HTML right in the middle of an if statement if you wanted it to always print.
You need to allow short tag in your php.ini to make <? work
else you have to write <?php } ?>
The second way should work like you described considering you have the closing php tags and < ?php
It does, if you have the right re-opening tag...
<?php
if (condition) { ?>
<!-- html code -->
<?php
}