How to get page title in magento? - php

Any way to get the page title in magento...I Have a script live person..on this I need the current page title ..So can anybodey tell me how i get the current page title?

use this code
$this->getLayout()->getBlock('head')->getTitle();
you can use this code in your phtml file

To get the title without the Prefix (site name):
<?php echo str_replace(Mage::getStoreConfig('design/head/title_prefix'), '', $this->getLayout()->getBlock('head')->getTitle()); ?>

Related

Get the title of another page in PmWiki

I have a valid page name that I need to resolve to a page title. Example:
Main.TargetPage
(:title Page One:)
I am the page of which the title needs to be got.
Main.CurrentPage
(:title Example Page:)
I am the page that the PHP script is being run from.
How can I get the title of Main.TargetPage from Main.CurrentPage?
You can get the title of a page with this function call:
$PageTitle = PageVar(ResolvePageName('Main/TargetPage'), '$Title');
You can get the other's page title by command {Main.TargetPage$Title}, see official docs:

how to get a list of wordpress used shortcodes with parameters from a pageusing php or jquery?

I have wordpress page with the following shortcodes
eg
page1
[myshortcode id='1']
[myshortcode id='2']
[myshortcode id='3']
... etc
Another has
page2
[myshortcode id='4']
and another has
page3
[myshortcode id='5']
What I want to do is get a php list of all the shortcodes on any selected page, eg page2, with the paramaters, i.e. the id.
The reason for this is I am writing a plugin wrapper to take an existing shortcode off a page and 'ajax' it, as a link in the currently generated code refreshes the whole page.
So my question is, how do I get a list of used shortcodes with paramaters from a page, using php or jquery?
You should check this out: http://codex.wordpress.org/Shortcode_API
Apparently all shortcodes are listed inside the $shortcode_tags:
<?php
global $shortcode_tags;
echo "<pre>"; print_r($shortcode_tags); echo "</pre>";
?>
You should be able to use this to find the active shortcodes on a PHP page, I guess.

How to get the title of a page in Laravel

I set my title of the page like this in the blade view template:
#section('title', 'Example.com - Welcome to Example.com for all your needs')
This is working well. Now I want to know how can I access/print the current page title in the body part?
I mean for getting the current URL, we can use Request::url(). Is there a way that I can get the current page title?
I don't know of a way to do this in Laravel, but this is easily accomplished in Javascript/JQuery:
$(document).ready(function(){
console.log($("title").text());
});
Will print the title of the current page to the console. You can assign this value to an element by targeting it's id $("#id_of_element") or class $(".class_of_elemnt") and setting the text to the title's text:
$("#id_of_element").text($("title").text());
Hope that helps!
I think it's not a good idea to set the page title with hard code in layout file.
one of the best ways is to have a default page title in layout and override it in every view page.
just like below :
layout title :: {{ isset($title) ? $title : 'page title' }}
You can print your page title using
#yield('title)
wherever you want.

Contao: Frontend - Get theme section of another page - not the current page

I would need to reach a custom section by page id (or PageModel Object), but I don't find a way to get the FrontendTemplate. I would like to use it in a dropdown navigation to echo a custom section of the hovered (parent) page.
If somebody will search for, the answer is:
<?php
$articles = \ArticleModel::findPublishedByPidAndColumn($id, $column_name);
echo static::getArticle($articles[0]); // for ex. the first article
?>

PHP code to create hyperlinks to the homepage?

I have a php site template and i want to create hyperlinks to the homepage on the internal pages. I tried this code which works in wordpress but doesn't work on my template: anchor text
What alternative code i can use to replace <?php echo home_url(); ?>, so it will work on my php template?
edit:
This worked Homepage! but i have another problem. In my php template the most recent pages are displayed on the homepage in a same way as a wordpress site. For the inner pages I am using this code page title to create hyperlinks for the page title similiar to the blog posts in wordpress. The problem is that the pages on the homepage are linking to the homepage not to the page url. For exmple, page with title Blue Widget has this page url domain.com/blue-widget, but when the page is displayed on the home page the page title is linking to domain.com.
How can i make the page title that are displayed on the homepage to link to they corresponding page url and not to the homepage. The same way blog posts that are dispalayed on the homepage of wordpress site are linking to they blog post pages.
Homepage link is just (when you have one domain):
Homepage!
Create a constant, somewhere in a central place like a config file. Then use it throughout the script.
define ('SITELINK', 'http://www.stackoverflow.com');
And in your template:
Go to home!
Or you can wrap it into a function:
<?php
function home_url(){
return SITELINK;
}
?>
Go to home!
Go to about page!
For referring only homepage:
In php
echo 'anchor text';
In Html
anchor text
Use "/" to redirect to home page from any other page.
The problem with $_SERVER['SERVER_NAME']; is it can be unreliable on some instances such as subdomains, etc...
Here is WordPress' Reference Manual: http://codex.wordpress.org/Function_Reference/network_home_url
In WordPress you can use:
$url = network_home_url();
echo $url;
So for you example it would be:
anchor text
Hope that helped.
<?php
function home_url(){
?>Go Home<?php
}
home_url();
try to use $_SERVER['SERVER_NAME']; to get the home URL
Home

Categories