How to edit <?php print $linked_site_logo; ?> - php

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.

Related

What is the best and most reliable way to call other templates into page.php in Wordpress?

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');

Magento modify the final output in all pages

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.

Wordpress contact form (404 not found)

I created a template on WordPress and I made an html form. It works well in HTML but doesn't work when used on WordPress. It seems that it doesn't find my contact-send.php page and it displays a 404 Error page.
My permalinks were on default and it didn't work.
Does anyone know how to fix this?
If any of my code is needed, I'll post it. I just didn't because I think it's not a code error once it doesn't find contact-send.php.
Use an absolute URL for the target of your form instead of just action="contact-send.php".
But unless you have particularly unusual requirements for your contact form, you will likely have better results using one of the many popular contact form plugins like Contact Form 7.
Using a well-maintained plugin ensures stability, and more importantly, security. Don't reinvent the wheel if you don't have to.
Your problem can be caused due to 3 reasons.
Giving wrong path in action tag. Using <?php echo get_template_directory_uri(); ?>/contact-send.php will solve this problem.
Missing contact-send.php page in the themes folder. This problem can be solve by adding the page to the themes folder.
Improper .htaccess file. This can be solved by recreating the code for your .htaccess file from Dashboard > Permalinks and paste it in the .htaccess file in the WordPress root directory.
I am giving the explanation in the assumption that your template file is directly in the themes folder.
Add <?php echo get_template_directory_uri(); ?>/contact-send.php. When you write contact-send.php only then it don't find your file which is in your theme. So use this <?php echo get_template_directory_uri(); ?>/contact-send.php in form action. This change may be helpful.

Is there a way to know which PHP file generated a page in Wordpress?

I am trying to make some changes to PHP files in Wordpress, but it is taking me a long time to find which PHP file to edit. Is there a way to know which PHP file generated a given page?
Thanks!
More information:
I understand the basic outline of Wordpress templates like header.php and single.php. However, I am having a hard time walking through the many theme-specific template files and finding which one serves what purpose. Specifically, I am looking at a generated webpage and attempting to edit it. And I am resorting to inserting tags inside each of the probable template files until I find the right one. Is there a way, perhaps through dev-tool, to see which php file generated the DOM?
It is possible to get a list of all the included files through the get_included_files() function in PHP.
Here is a PHP script to set in the footer.php file of your template :
// echo '<!--'; // you can display this code or show it in an HTML comment
$files = get_included_files();
if ($display_only_theme_files === true) {
$theme_folder = get_template_directory();
foreach ($files as $key => $file) {
if (strstr($file, $theme_folder) === false) {
unset($files[$key]);
}
}
}
print_r($files);
// echo '-->'; // you can display this code or show it in an HTML comment
This script will show you all the included files related to your template. In other words, you will have the possibility to know which file template is used.
Please, be sure to use this code only on your development mode and to delete it when you will be in production.
It is sometimes difficult trying to work out which template file within a theme is being used. First thing worth considering is the Wordpress template hierarchy. This page from the Codex and in particular the diagram should be helpful to you;
http://codex.wordpress.org/Template_Hierarchy
Secondly, it can help if you add the body_class method to your theme's header.php. It is designed to allow greater control of CSS through additional specificity, but by viewing the source through your browser dev tools you can quickly look at the classes added to the body tag and work out which template is being used;
http://codex.wordpress.org/Function_Reference/body_class
How about putting a unique HTML comment in each template file?

How to NOT write file_put_contents on EVERY page load

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

Categories