i need to parse the final output contents (html) of all the pages of this CMS, (using PHP and my own class)
something like:
<?php
echo get_magento_output();
to:
<?php
echo parse_content(get_magento_output());
Can i create an extension that do this? if not, what files i must modify to modify the output in all pages?
To answer your question, yes, you can do it here:
magento/app/design/frontend/enterprise/themename/template/page/1column.phtml
subbing in 1column for whatever the name is for you. However, I would beg you not to do this. If you want to modify things on all pages, change the theme or template. Theres tons of documentation out there on Magento Themes, and there are plenty of places you can alter phtml files to change your output to be correct the first time around.
as example, we have the default header:
/app/design/frontend/enterprise/default/template/page/html/header.phtml
If you want to change css classes, of header for example, change:
<div class="header">
to
<div class="my-new-header">
the phtml functionality is strong, and you can accomplish a lot in these files.
Related
I'm building a digital archive using Omeka Classic and I would like to place little flag icons that link to versions of my site in different languages in the header, so I’m trying to figure out how to tinker with the theme’s code (The theme is Minimalist). I don’t have a ton of programming experience, but I think I need to go to /themes/minimalist/common/header.php and add a php echo statement within the <div class="site-title"></div> tag to place my icons within the header section. And that’s as far as I can get on my own.
Questions:
Do I need to define my icons as a variable somewhere and then write an echo statement to the effect of: <?php echo VARIABLE; ?> Php at this level is above my head, but it looks like this is how content is being generated.
Could I add an echo statement in the location suggested above without using a variable or constant? Maybe something like this? <?php echo <a class="lang" href="URL to Arabic language site"><img src="URL to flag image"/></a>; ?> And then I could style the .lang class to push the flags to the bottom right corner of the site-title div.
Just wanted to ask before I start experimenting and break the site.
I've inherited a very large Drupal site and need to edit the content in $linked_site_logo as below, but I have no idea where to find this file.
<div id="logo"><?php print $linked_site_logo; ?></div>
What is typically the file structure for a large-scale Drupal site and where should I begin looking to edit this? I haven't been able to locate the file.
There seems to be an answer on a drupal community which might help you. https://www.drupal.org/project/corolla/issues/1472416 - which suggests the code maybe in the page.tpl.php file
However, your best bet might be to use your terminal or code editor to do a search across the code base for the line of code, as there could be multiple references to the logo being included.
It's probably in your theme template files page.tpl.php or in include header file. Use theme debug mode, put this in your settings.php at the end of the file:
$conf['theme_debug'] = TRUE;
Than inspect element using your browser and see where elements come from.
My Wordpress website uses two push menus, both of which I initially had situated in the header.php file. It wasn't until I started needing to use a lot of PHP code in one of these menus that I decided to have them in separate files and call them into the page structure via PHP commands. Ive been wondering what would be the best way of going about this and would appreciate any advice on whether I'm doing it correctly. Below is the code from the simpler of the two menus – I've saved this as mobile-menu.php.
<div class="mobile-menu">
<nav class="main-menu" id="mobile">
<?php wp_nav_menu( array( 'theme_location' => 'header' ) ); ?>
</nav>
</div>
This isn't a particularly long list of code, but the other menu (shopping-basket.php)is a lot longer as it uses PHP from a plugin I've installed, and I don't want masses of code in my header.
I've then called both menus into my page.php using "include" commands, like I have with the header and footer – for example:
<?php get_header(); ?>
<?php include("mobile-menu.php"); ?>
<?php include("shopping-basket.php"); ?>
Is this recommended? It seems to work okay, but I've noticed that despite saving the files as PHP templates with a .php extension, they're showing up as HTML files when I have a look in my FTP account. Why would this be?
Any advice or info would be appreciated as I can't really find any concrete info on this online and have got to the stage that I'm at by searching through forums etc.
You would be best off using get_template_part() instead of include().
Load a template part into a template
https://developer.wordpress.org/reference/functions/get_template_part/
You should put the contents of mobile-menu.php into templates/menu-mobile.php (Note that I've reordered the name for least- to most- specific) and templates/shoppingbasket.php. Call them as so:
get_template_part('templates/menu','mobile');
get_template_part('templates/shoppingbasket');
I am completely new to PHP (2 weeks) and I have created a simply script for Joomla that will save parameters from my my admin area options and put those values into a CSS format and save the file. It's a whole long script of CSS but here's an example of it...
<?php
ob_start();
?>
<?php
////////////// Custom colours set from the admin panel
if ($this->params->get('templateColor'))
{
?>
/* <?php echo($template); ?>: Custom Auto-Generated CSS Colors As Set in Admin Template Parameters */
body.site {
border-top: 3px solid <?php echo $this->params->get('templateColor');?>;
background-color: <?php echo $this->params->get('templateBackgroundColor');?>
}
<?php
}
?>
<?php
$googlefontcss = ob_get_contents();
ob_end_clean();
file_put_contents('templates/'.$template.'/css/googlefonts.css', $googlefontcss);
?>
Heres my problem, all of these things are stored in a helper file which is called from my index file, but this has the effect that the CSS file is created every time that the page is loaded rather than when I adjust and save my params in the backend. Surely, if I got a lot of traffic, this is going to stress the server even though the css file is quite short (its longer than shown here).
Being a newbie, I have no idea how I would avoid this problem and instead only have the file written when the options are changed and saved. Anybody suggest a better way?
I'm really confused about why you would do this at all. First, Joomla has a way to save parameters for a template and to use them, which you are doing. It also has a standard way to include a css file in your template. You can do this easily with a plugin if you don't want to addStyle() directly to the the template file. Also for google font api just look at how protostar does it.
I really think you need to look at how templates work in Joomla --- it's not modifying the core to modify your template index unless you are using one of the included templates --- in which case copy it, which you can do with one click in 2.5 and 3.
If you really absolutely have to do this, make a plugin. There are a lot of examples in the JED of plugins to include a file in a template. http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/head-code
I'm certain I can use PHP to accomplish this task, but I'm not sure how.
What I currently have is a faux news (ha ha ho ho) site for practise here.
http://puu.sh/402Rl.png
For Browse News, I would like all html documents within a specified folder to be shown in the format I have
SAMPLE
<p class="content centeralign">
8.12.13 <!-- ARTICLE NAME -->
</p>
<hr noshade></hr>
Although it's not much, setting up a way to do this automatically would save some time.
Here is how I would imagine the logistics behind this would function ----
All HTML files will be listed in a folder
They will all have a consecutive order based on the date they were created (e.g. 1.html, 2.html, 3.html etc.
PHP would find each document and add it in the right order
A bit inside the file would define the title (meta tags?)
That seems a really bad way of doing it, but anyway.. You want to be you want to be using the directory functions. Specifically http://www.php.net/manual/en/function.readdir.php
A good idea would be to set up a MySQL system for this, but it is achieveable with PHP only.
You could get all .html files in the folder with glob, and then include them with this code:
foreach (glob("/htmlfiles/*.{htm, html}") as $filename) {
include "$filename";
}
The nice thing about this, is that it's sorted alphabetically and numerically too.
Edit: You would then use this system twice, with two folders, one for the meta tags/title, and one for the page itself. Again, not the best way to do it. You should really check out a CMS.
If you used MYSQL, you can still get all html files from the folders as you are now, but just use MYSQL to make simple basic references, such as the filename, date, category, etc. Then you don't need to use complex (and likely failing) file and directory code to determine when a file was created and which order to serve them in. The DATE in your MYSQL would be when to serve them.
To answer your meta questions, I would have a header.php file with all the meta data in for the site (doc declaration, titles, css links, etc) and then each individual file could have a variable to pass to the header when it's included.
eg
File: about.php
$PageTitle = 'About';
include_once('header.php');
<some more code>
<h1>$PageTitle</h1>
File: 1.php
$PageTitle = 'News about something';
include_once('header.php');
<some more code>
<h1>$PageTitle</h1>
File: header.php
usual code, doc declaration, head, etc
<title>$PageTitle</title>
So at the start of each file you declare what the title will be then include header.php. The title is used on the meta title (so your browser and tab etc) and the var in the file can also be used on headers (ie h1, h2) and links if needed.
you could do all this without MYSQL still, but using a database to even just reference things like date_of_creation - last_update_date - author, etc, could save you headaches, but is up to you how you want to do it and what skills you have etc.