Jump to content

Recommended Posts

Posted

I know this is relatively easy php stuff, but I can't get it right.

This is what I have for my title tag, right from the default install:

<title><?php echo $page->get('headline|title'); ?></title>

But I want to append the site name to the headline with a vertical line in between. What's the best way to do that?

Sorry - I'm still fumbling through learning php and was unable to find a snippet for this that wasn't specific to Wordpress.

Aaron

Posted

Erm... No PHP required - just add " | Your Site Name" before the closing </title> tag and you're done.

I think that's what you meant anyway?

Posted

My goodness, I'm a dumbass :P

Thanks Pete. I hadn't thought about adding the site name outside the php closing tag. Sometimes I like to make things complicated.

Posted

Don't worry, when I started with PW everything I tried to do had an easier way of achieving it ;)

Quite often I'll scratch my head over something for hours one evening and then have a eureka moment an solve it the next morning after sleep and caffeine :)

Posted

PW is a flexible tool. So if you wanted a way to set some site-wide settings and manage them from the admin you could:

Create a template called something like "settings". This can be a file-less template. Create fields for the settings you wish to have, for example 'sitename' and 'companyslogan'. Add the fields to the settings template. Create a page with the template 'settings'. The page can be named anything but let's also call this 'settings'. Make the page hidden and publish. Now you can use this data in your templates using the PW api.

$settings = $pages->get("/settings/");
<title><?= $settings->sitename; ?> | <?= $page->get("headline|title"); ?></title>
<h2><?= $settings->companyslogan; ?></h2>

This is only one way. Another way would be to do this settings in the config file.

  • Like 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...