Drupal 7 custom logo in page.tpl.php not displaying on all pages - drupal-7

I have a Drupal 7 site with a custom sub theme based on Zen. I have a custom logo that I placed in the page.tpl.php header div. The problem I'm having is that the logo only shows up on the first "main" pages, but not "subpages". Excuse my terminology here trying to explain this. What I mean by subpages is any page that is further down the chain or occurring after the first forward slash. Below is an example of what I mean by "main" pages and "subpages". All these "main" pages are directly after the first slash after the website name. The logo doesn't show up on any pages that occur after these main pages (subpages). All my pages are made using the Pages module, however, the subpages have a path using %term, for example /support/%term or products/%term.
What am I missing and what do I need to do to make my logo in page.tpl.php show up on all pages of my site? Am I supposed to create a new page.tpl.php file for the pages using /%term?
Main pages - logo shows up:
mysite.com/about
mysite.com/products
mysite.com/support
mysite.com/contact
Sub pages - logo doesn't show up:
mysite.com/products/product1
mysite.com/support/product1-support

If I understand you correctly, the quick fix for that is to make sure your logo's path starts with '/', like so:
<img src="/sites/all/themes/customZen/images/logo.png" />
But then if path of the theme changes everything will break, so don't do this.
If you place the logo using CSS as a background, use relative URL (it is relative to the path of .css file)
Or you can do something like this in your page.tpl.php:
<img src="<?php url($directory . '/images/logo.png'); ?>" />
$directory is the directory the template is located in, e.g. sites/all/themes/customZen.
Full list of page.tpl.php variables can be found here: https://api.drupal.org/api/drupal/modules%21system%21page.tpl.php/7.x

Did you solve this?..Well, if you didn't, try with this in your page.tpl.php paste this:
<img alt="" src="<?php echo drupal_get_path('theme', 'customZen');?>/images/logo.png">
Good luck!

Related

How to set HUGO.io landing page?

I'm trying to set one of my sub-pages as a landing page in my hugo.io page setup. But all I can find so far is the hint to change the content of the home.html file in my layout folder.
This is not what I want to do, because by this I will duplicate the existing layout file for the sub-page whis is error prone. Is there any Site parameter that sets my sub-page "Portfolio" to be my landing page?
My setup:
|content
|posts
|about
|portfolio
|work1 (This is a page bundle)
|work2 (This is a page bundle)
index.md (Page Content File)
_index.md (List File)
My template setup:
|layouts
|_default
list.html
single.html
|portfolio
list.html
single.html
index.html
home.html
So layouts/portfolio/list.html ranges through all my portfolio work. This works fine. The file is used when I navigate to localhost:1313/portfolios.
But for having the same content on localhost:1313/ I understand to duplicate the layoutfile to layouts/home.hmtl -> Is this correct? This seems utterly laborious to me. Is there a more convenient way to tell hugo "use the file content/portfolios/_index.md as my landing page"?
Hope you can help me, Thanks in advance!
One solution is to move the content of layouts/portfolio/list.html to a partial, then include this partial in both layouts/portfolio/list.html and layouts/index.html. This way you will not have to duplicate the code you use to list all of your work.
I would also advice you to read the documentation on order lookup for templates, specifically the section related to the home page, as this explains the order of which template files are included.

Having trouble with implementation

I have spent 2 hours + on the lightbox. I have checked paths to CSS and Javascript. I have used both the included jquery and Google's imported JQuery.
When I click an image it opens a new window with that image larger on a white background. I want it to overlay the current page with <> and x.
You can see an example: http://demopbdesignsource.tierstrategies.com/a.aspx
Thanks
Looking at your code on your page I do not see where you are calling the lightbox.js script - that needs to be called right before the body close tag.
Also lightbox help states : If you already use jQuery on your page, make sure it is loaded before lightbox.js. - ◦Include the Javascript at the bottom of your page before the closing /body tag:
I used the lightbox-plus-jquery.js and called that just before the close of the body tag and it worked. I called the lightbox-plus-jquery.js just before the close of the body tag because it has both jquery and lightbox combined.
I am still working on the page and I am just using html not .net but the lightbox would work the same. If you look at my source you will see the script call right before /body tag.
http://just-in.com/recycledDresser/index.htm
Hope this helps.
Debra W.
You need to call the Lightbox script.
Something like
Placing it in the line before the line works for me.
Both
http://demopbdesignsource.tierstrategies.com/X/LightBox.css
and
http://demopbdesignsource.tierstrategies.com/X/LightBox.js
cannot be found.
The link provided in the question is giving 404 right now.
but I think you just need to follow the steps given at
http://lokeshdhakar.com/projects/lightbox2/
to set up lightbox.
you may have missed either of the following :
Include the CSS at the top of your page in your <head> tag:
<link href="path/to/lightbox.css" rel="stylesheet">
Include the Javascript at the bottom of your page before the closing </body> tag:
<script src="path/to/lightbox.js"></script>

CakePHP 3.x Sidebar is not showing any content

I was trying create a left side menu bar. I used the following code in my layout file Templates/Layout/admin.ctp
// Create the sidebar block.
$this->start('sidebar');
echo $this->fetch('sidebar');
echo $this->element('sidebar/left_menu');
$this->end();
But the sidebar is not showing in the page. The Left menu sidebar file is located at Templates/Element/Sidebar/left_menu.ctp
Any help will be appreciated.
There are two things I can point out:
The default directory for templates is src/Template and not Templates
As you are starting the block, fetch('sidebar') will return empty. Try putting it after the end of the block
// Create the sidebar block
$this->start('sidebar');
echo $this->element('sidebar/left_menu');
$this->end();
// Display the sidebar
$this->fetch('sidebar');

Drupal 7 > Print Module > print links missing on custom module and views

Print links are missing on my custom module which creates a custom form. Print links are also missing on my custom views. I searched the internet and people pointed me to configuration menu for print module to look there and check "Show link in system(non content) pages. I did that and I even activated it for all pages with no luck.
What am I doing wrong?
As far as I know, the Print module only outputs links on node pages. I also found the following on the module page
This module allows you to generate the following printer-friendly
versions of any node.
What I sometimes do to solve this is to make a custom block, which takes the page URL and prepend /print. E.g.
<?php $current_url = getenv('REQUEST_URI'); ?>
<img src='/sites/all/modules/print/icons/print_icon.png'>
<a href='/print<?php print $current_url; ?> '>Printer-friendly version</a>
Source of example

Cakephp images from css using themes

im using themes in an app im doing, and need a global css/img/js folder
i have tried using app/webroot as this folder, but cant get any css from a theme to show the images.
I have a setup like :: /app/views/themed/my_theme/webroot/css/file.css
With some css that looks like:
...
body{
background-image: url('../img/file.jpg');
}
...
if i have the image in /app/views/themed/my_theme/webroot/img/file.jpg everything works 100% but when i put the image in /app/webroot/img/file.jpg it will not show. i have tried all sorts of combinations for the
i have also tried using a plugin dir like app/plugins/my_plugin/webroot/img/file.jpg but the various paths ive tried will not show the image either.
any ideas how i can get the image to show? i dont mind if its for webroot/ or in plugins/xyz/, just as long as i can use the same image in many different themes with out having to duplicate the images
when the image is in /webroot/img i can use the full path like url(http://locahost/my_app/img/file.jpg) and it works.
things that dont work
url("img/file.jpg")
url("/img/file.jpg")
url("../img/file.jpg")
url("/../img/file.jpg")
url("../../img/file.jpg")
thanks.
In your CSS file
body{
background-image: url('/img/file.jpg');
}
This will use the root area to find the image in /app/webroot/img/file.jpg
CSS has urls for images relative to the path it is placed in.
CSS files from my_theme are linked like site.com/theme/my_theme/css/style.css in the browser. So if you want to use an image from app/webroot/img in your theme's CSS, use url(../../../img/image.png)
I have not tried that but the cookbook says:
If you want to keep your theme assets
inside app/webroot it is recommended
that you rename app/webroot/themed to
app/webroot/theme.

Resources