OllieMackJames Posted August 4, 2016 Share Posted August 4, 2016 How can I add the domain name to the end of this: <title><?php echo $page->get("seo_title|title"); ?></title> par example: seo_title = Wonderful Catchy Thingies then the ouput will be: <title>Wonderful Catchy Thingies</title> And I want it to be: <title>Wonderful Catchy Thingies | Mydomainname.com</title> Thanks! Link to comment Share on other sites More sharing options...
alxndre Posted August 4, 2016 Share Posted August 4, 2016 Assuming you want this in the current template and you want the root domain , your code should be : <title><?php echo $page->get("seo_title|title") . " | " . $pages->get('/')->httpUrl; ?> 1 Link to comment Share on other sites More sharing options...
OllieMackJames Posted August 4, 2016 Author Share Posted August 4, 2016 Thanks Alxndre', I need one stepmore, cause this adds the Url as in like: https://www.domainname.com I have now done it like this: <title><?php echo $page->get("seo_title|title"); ?> | Domainname.com</title> I think this will work for me, I hardly ever do any of this html coding, hence the noob question. Once again Alxndr' thanks for thinking along! Link to comment Share on other sites More sharing options...
ottogal Posted August 4, 2016 Share Posted August 4, 2016 Try this: <title><?php echo $page->get("seo_title|title") . " | " . $config->httpHost; ?> See https://processwire.com/api/variables/config/ 3 Link to comment Share on other sites More sharing options...
szabesz Posted August 4, 2016 Share Posted August 4, 2016 @OllieMackJames Are you looking for something like these? <?php echo parse_url($page->httpURL,PHP_URL_HOST); ?> or <?php echo $config->httpHost ?> @ottogal was faster than me 1 Link to comment Share on other sites More sharing options...
fbg13 Posted August 4, 2016 Share Posted August 4, 2016 You could just add your own option in config.php $config->prefix_sitename = 'my site name'; $config->prefix_title_separator = ' - '; And use like this: <title><?php echo $page->title . $config->prefix_title_separator . $config->prefix_sitename ?></title> 1 Link to comment Share on other sites More sharing options...
OllieMackJames Posted August 4, 2016 Author Share Posted August 4, 2016 2 hours ago, ottogal said: Try this: <title><?php echo $page->get("seo_title|title") . " | " . $config->httpHost; ?> See https://processwire.com/api/variables/config/ Thanks ottogal, taht is one step forward, it now shows www.domainnam.com - I want just Domainname.com Link to comment Share on other sites More sharing options...
OllieMackJames Posted August 4, 2016 Author Share Posted August 4, 2016 2 hours ago, szabesz said: @OllieMackJames Are you looking for something like these? <?php echo parse_url($page->httpURL,PHP_URL_HOST); ?> or <?php echo $config->httpHost ?> @ottogal was faster than me HI szabesz, thanks, <?php echo parse_url($page->httpURL,PHP_URL_HOST); ?> gives me the www variant as well. Just now saw the reply from fbg13, which gives me exactly what I need, thanks! Link to comment Share on other sites More sharing options...
OllieMackJames Posted August 4, 2016 Author Share Posted August 4, 2016 17 minutes ago, fbg13 said: You could just add your own option in config.php $config->prefix_sitename = 'my site name'; $config->prefix_title_separator = ' - '; And use like this: <title><?php echo $page->title . $config->prefix_title_separator . $config->prefix_sitename ?></title> This is the one! Added the 2 lines to my config.php and added this: <title><?php echo $page->get("seo_title|title") . $config->prefix_title_separator . $config->prefix_sitename; ?></title> Works like a charm, thanks fbg13! Link to comment Share on other sites More sharing options...
ottogal Posted August 4, 2016 Share Posted August 4, 2016 Make the file /site/config.php temporarily writeable and add this line: $config->httpHost = 'domainname.com'; You can also add a "Whitelist" with the variants you want to allow in this way: $config->httpHosts = array('yourdomain.com', 'www.yourdomain.com'); 3 Link to comment Share on other sites More sharing options...
OllieMackJames Posted August 4, 2016 Author Share Posted August 4, 2016 Thanks ottogal, that one also works, much appreciated. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now