magento customize html print order - php

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

Related

How to adjust HTML when website is in PHP

I have a Wordpress theme for a new website. I want to make some HTML adjustments but I realized that the website has only PHP scripts and of course the CSS file. For instance, I need to adjust the website name but cannot find H1 tags. I do not have any PHP knowledge. Please advice. Many thanks!
Screenshot
<?php echo "<div>html here</div>"; ?>
You can as many php chunks as you want
example :
<?php echo "<h1>html here</h2>"; ?>
<?php echo "<span>html here</span>"; ?>
Wordpress is a bit different from vanilla PHP instead of echoing out HTML with the title:
<?php echo "<h1>The Title</h1>"; ?>
It uses a function/hook called wp_title(); that you can find in header.php.
But to modify it you would have to in to functions.php and edit the function and for that you need some basic PHP knowledge.
Here is some documentation on the wp_title() function/hook.
https://developer.wordpress.org/reference/hooks/wp_title/

How to make a PHP template without a database?

I'm working on a small company "brochure" website. I have a few pieces that repeat for example:
Menu
Submenu
Footer
Subheader
Say a page "comparison.php" needs to have all of the above and then content. I could do which is how I started:
<?php include '/partial/menu.php'; ?>
<p>This is a product comparison</p>
<figure>
<figcaption>Probably an image here</figcaption>
((image))
</figure>
<table>
<tr><td>Product 1</td><td>Product 2</td></tr>
<tr><td>Point A</td><td>Point B</td></tr>
</table>
<?php include '/partial/footer.php'; ?>
I'm thinking what a better way might be. Perhaps adding a directory content so then it becomes:
<?php include '/partial/menu.php'; ?>
<?php include '/content/comparison.php'; ?>
<?php include '/partial/footer.php'; ?>
This still feels clunky to me especially when I've got multiple subheaders and submenus depending on the page.
I've read online about templates with PHP but everything is with databases just inserting variables like, Programmers.SE - How to structure template system using plain PHP How would I go about streamlining this as much as possible without using a database? And please do not tell me to use a CMS, it's not an option.
Alright I think I figured out a methodology that is quite nice.
3 Main Files being used:
comparison.php
information_template.php
content/comparison.php
comparison.php
<?php
$pagename = 'comparison';
include('information_template.php');
?>
information_template.php
<?php include '/content/' . $pagename . '.php'; ?>
content/comparison.php
All of the content goes here
Now I can just make a page in my root and a page in the content for each one with the same format and it should work. I'll probably add some additional to comp.php something like $pagetype = 'information'; or $pagetype = 'review'; so I can then add to my information_template.php:
<?php include '/partial/' . $pagetype . '-subheader.php'; ?>
<?php include '/partial/' . $pagetype . '-toc.php'; ?>

Hide site content after login

Im creating a site using Adobe Dreamweaver CS6 and I have added a login function there. I have also added a Dynamic Text session MM_Username that displays the logged in users name in the page. However, my problem here is that every time someone is not logged in, dynamic text shows an ugly error message. I'd like to hide this content from my page every time someone logs in. Is there some simple solution to do it like wrapping the text with some php code? Any help would be appreciated since I've pretty much looked everywhere. Thanks in advance.
-John
From memory (been a few years now) I believe in the server behavior panel, there is an option to "show region if" or something similar.
Failing that you can wrap the offending content in an if similar to this:
<?php if (isset($_SESSION['MM_Username'])) { ?> your content here <?php } ?>
Or this which I personally find more readable when mixing html and php:
<?php if (isset($_SESSION['MM_Username'])) : ?> your content here <?php endif; ?>
You can check firstly when user logged_in, If he/she is logged in then,
if(isset(session['var'])){ ?>
< your html content here using CSS hide property >
<?php } else { ?>
< Your html content goes here using CSS show property>
<?php } ?>
The code does exact of what you want for me; hope it helps
<?php if ($_SESSION['MM_UserGroup'] == 'teacher') { ?>
<div class="home"><img src="images/ico-folder.png" width="32" height="31" /></div>
<?php } else { ?>
<?php } ?>

Zend Framework 2 Navigation

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.

php excluding piece of html code?

I have a custom CMS here entitled phpVMS, and I want to exclude a piece of code, a banner for a single page. phpVMS is steered using templates, for instance, the main template that codes the general layout for all pages is entitled layout.tpl. So, like I said, this displays whatever is in the template, on all of the pages. I have however created a special control panel, and therefore require to exclude the banner, because it slightly destroys the theme of it. Is there any PHP code that excludes a piece of code on a single site? I need to remove a single div...
<div id="slideshow"></div>
...on a single page.
Basically, I could create a new template but this is a very long winded and unefficient way within this CMS, and the final result isn't that great - because I can't reinclude the mainbox div which is the box defining the content on the centre white bit of the theme - it's already in the layout.tpl.
I hope you can somehow help me, hope I've included enough information there.
Thanks.
I don't think you can do what you're asking in PHP, but you might be able to do this on the client-side, by either hiding the div (CSS display:none) or by removing it with JavaScript. You might be able to do something like:
<?php
include("layout.tpi");
if (condition)
{
// Javascript:
echo "<script>document.getElementById('slideshow').style.display = 'none';</script>";
// OR jQuery:
echo "<script>$('#slideshow').hide();</script>";
}
?>
If you use a variable to determine you don't want to include the div, you could do this:
<?php if ($include) { ?>
<div id="slideshow"></div>
<?php } ?>
OR
<?php
if (!$include)
echo "<!--";
?>
<div id="slideshow"></div>
<?php
if (!$include)
echo "-->";
?>
EDIT: Obviously, there is no good reason to use the second method. The second method will only comment out the HTML so it will still show up in the source.
I'm not sure if this is what you are looking for, but seems simple
<?
$template = true;
if($template) {
?>
<div id="slideshow"></div>
<?
}
?>
On the template, you could have some code that reads:
if($_SERVER['PHP_SELF'] == /*control panel file*/) {
//exclude
}else{
//include
}

Categories