Header information is repeating on every page. How do I remove it?

Discussion in 'HTML & Website Design' started by leftysgirl, Aug 21, 2014.

  1. #1
    Hi,

    I have a header with script that is repeating on every one of my pages. How do I remove this? I would really like to be able to seo each page as its own :)
    I did not see anything standing out in my header.ctp/public.ctp file.

    So I am wondering if I need to find another file? My website is built with CakePHP. Maybe a controller file or something on the lines of that?
     
    leftysgirl, Aug 21, 2014 IP
  2. KevJ

    KevJ Active Member

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #2
    You could call your SEO from a separate so you don't get mixed up, I do mine like this ,

    homepage header

    {include file="$template/header-seo.tpl"}
    
    //then create a file called header-seo.tpl and inside write my seo as follows;
    
    {* START HOME PAGE SEO *}
    {if $filename eq 'index'}
    <title>blah blah blah</title>
    <meta name="description"  content=""/>
    <meta name="keywords" content="/>
    <meta name="robots" content="index, follow"/>
    <meta name="revisit-after" content="1 days"/>
    <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="public">
    <META HTTP-EQUIV="EXPIRES" CONTENT="Mon, 22 Apr 2015 11:12:01 GMT">
    
    {* START DOMAIN PAGE SEO *}
    {elseif $filename eq 'domainchecker'}
    <title>title</title>
    <meta name="description"  content=""/>
    <meta name="keywords" content=""/>
    <meta name="revisit-after" content="1 days"/>
    PHP:
     
    KevJ, Aug 22, 2014 IP
  3. leftysgirl

    leftysgirl Greenhorn

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    Thank you for taking the time to write this out for me, and explaining.

    I do understand your directions, but to make sure I completely understand correctly, will I need to rename the tpl file
    for each webpage that needs a new seo header and change that name in each page's header?..and will I include the tpl file in the same folder as the header.ctp or somewhere else?

    I am assuming, if I implement this, would this added file and command help overwrite the existing headers information? I am just concerned that I would have duplicate header info, like 2x meta descriptions, 2x titles, etc.

    I look forward to seeing if this is the answer to my problem. I have been having a hard time changing something that should be simple.
     
    leftysgirl, Aug 23, 2014 IP
  4. leftysgirl

    leftysgirl Greenhorn

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #4
    I am definitely doing something wrong. I tested it to see if I could get this to work, and the {include file="$template/header-seo.tpl"} kept appearing on my homepage's header as text.
     
    leftysgirl, Aug 23, 2014 IP
  5. KevJ

    KevJ Active Member

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #5
    Well you need to adapt this for your own site, I use WHMCs which uses templetes,

    In your header.php file place this in the <head> section

    {include file="header-seo.tpl"}

    Create the file header-seo.tpl and place it in the same folder as your header.php file

    Then in the header-seo.tpl file try placing the below , This will be the SEO for your index.php page

    {* START DOMAIN PAGE SEO *}
    {elseif $filename eq 'index'}
    <title>title</title>
    <meta name="description" content=""/>
    <meta name="keywords" content=""/>
    <meta name="revisit-after" content="1 days"/>

    All you do for each page is change this line in the header.seo.tpl file for the page name {elseif $filename eq 'index'} Would be index.php {elseif $filename eq 'contact'} would be contact.php and so on.
     
    KevJ, Aug 23, 2014 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    28,813
    Likes Received:
    4,535
    Best Answers:
    123
    Trophy Points:
    665
    #6
    Cake doesn't use tpl files so the code given is just for your guidance.

    Did you develop the cake site? or are you just maintaining it?

    Go to /views/layout/default.ctp and read the code in there.

    The key "takeaway" from @KevJ's example is that you add to the header section, rather than remove it. Therefore you need to go into the controller and set the variables that you want to be displayed for the page. I'm guessing it's things like title and meta tags that you want to be able to manipulate.
     
    sarahk, Aug 23, 2014 IP
  7. leftysgirl

    leftysgirl Greenhorn

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #7
    Thank you Sarahk! That is good to know information. I had the site developed for me years ago, and developed an interest this year to learn how to do simple tasks myself,..but I am not sure how simple this is. Basically, I can only go as far as the information given, because the I came up empty handed researching this task.

    I found a lot of folders that contained subs titled, views/layout/default.ctp.. I am going to provide them in a few minutes...as I gather the details. (My daughter nudged my hand as I was typing, and I hit submit too early) :)

    Here are some of the files I found that seemed to be the most relevant. The information all appeared to be the same in each location. So, I am not sure which one would be from the correct path to work with:
    cake/console/templates/skel/views/layouts/default.ctp
    cake/libs/view/layouts/default.ctp
    then there were some more with..
    xml,rss & js all in cake/console and cake/lib

    I think I may need to go into my homes controller to set the variables as you suggested, but I am not certain how to do so. Yes, I would like to arrange for me to be able to save my own title, meta information and Htags on each page individually. Do you where I could find some examples of how to write this in the controller section? If I am understanding correctly, I could use Kevj's header example in my header?
     
    Last edited: Aug 23, 2014
    leftysgirl, Aug 23, 2014 IP
  8. sarahk

    sarahk iTamer Staff

    Messages:
    28,813
    Likes Received:
    4,535
    Best Answers:
    123
    Trophy Points:
    665
    #8
    look for app/view/layouts/default.ctp

    definitely not console or libs!
     
    sarahk, Aug 23, 2014 IP