0

I need to edit someone's website. What I need to do is change the title. This sounds easy, but it's not (at least for me). This is how the relevant line looks like:

<title><?php echo Header::instance()->title; ?></title>
  1. What is this first part Header::? I've never seen that before.
  2. On the other files, I've seen:

    <h1 class="title"><?php echo $serial->name; ?></h1>
    

    That's being used to display the serial name. I wanted to use it as the title above, but it says "undefined variable: serial".

How can I change that?

rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
Mateusz Winnicki
  • 151
  • 2
  • 11

2 Answers2

0

You're editing a website made in : the header of the page (which should control headers, title and meta I guess) is controlled by a class named Header, which has an instance (get by instance()) and the <title> content is store in its title attribute.

The same scenario occured for the <h1>: an object, stored in the $serial variable has an attribute name which contains the name of the current page.

TL;DR

  • To change the website title, search the Header class and edit the title attribute.
  • To change the name of a page, find the right controller which generate the page and change its name attribute
Maxime Lorant
  • 34,607
  • 19
  • 87
  • 97
0

Most likely the Header class is setup as a singleton. Singleton is a design pattern that allows only 1 instance of a class to exist. In PHP this is done by created the __construct method as either a protected or a private method. The ::instance() methid is a public static method. Because it is static it can be called without instantiating the object, the static method constructs Header. because the method is part of the class, it can access the private or public constructor. See an example here:

Creating the Singleton design pattern in PHP5

The :: simply tells PHP you call a static method. instance() returns an instance of Header and Header contains a public property called title, which is then echo'd out with PHP.

The second question for the error. $serial is probably not defined at that point in your code.

Community
  • 1
  • 1
Tjirp
  • 2,435
  • 1
  • 25
  • 35
  • okey, i understand that , thanks ;) but if there is a static method , where can i find what its echo'd ? I've found the class but i cant find these words , which are displayed ;) thers no anything in cms, what is responsible for that ;) – Mateusz Winnicki Aug 11 '13 at 10:16
  • Where, its the property title from the Object Header. So its either: a) a property defined in the class Header, which is named title. Or a property defined in a parent class of Header (see if it extends or implements another another class). Or c) its retreived from the magic __get method, which returns something when you try to acces the title property. – Tjirp Aug 11 '13 at 22:10
  • Okey i got one more question, i managed to change that title, but id like to change order , now its title and name of serial after. How make it be , first name of serial then the title ? – Mateusz Winnicki Aug 12 '13 at 11:31