I'm trying to change headtitle on ZF2 but it always say "ZF2 Skeleton Application" when i paste it on FB
How can I change it?
I tried few things and cant make it work
I event tried raw HTML inside head tag to put it and it doesn't work, BUT on my other pages this works but don't know why
echo $this->headTitle('you are on '.$news.' ');
inside PHP ofc
If you want to set head title, Do not use 'echo' in front, just use:
$this->headTitle('you are on ...');
...in your view php file.
If you want to change the head title from inside a controller method use:
$this->getServiceLocator()->get('ViewHelperManager')->get('HeadTitle')->set('my title')
To my understanding you want to change the head title of the main (front page).
You can put the following in your layout.phtml page.
<?php echo $this->headTitle('you are on'. $this->translate($news))->setSeparator(' - ')->setAutoEscape(false); ?>
Related
I am trying to change the title of a page.
The default.ctp view has the following code:
<title>
<?php echo $this->fetch('title'); ?>
- Welcome
</title>
I'm trying to use the following code in the controller of the page:
$title = 'Overview';
$this->set('title');
But unfortunately I do not see see 'Overview - Welcome', but only the name of the function of the controller followed by ' - Welcome'.
Can anyone help me to find the problem why it is not working?
Don't know if $this->set('title') will work
I usually use the 'compact' function to set the variables as they're named.
Like this: $this->set(compact('title')); or just simply this $this->set('title', $title);
You can define what $this->fetch('title') returns using View::assign() function that sets block's value this way:
$this->assign('title', $title);
See more in the documentation about view blocks.
I think instead of:
$this->set('title');
you must use:
$this->set('title', $title);
I am using InteliJ and really love using it. One of the questions I have is this:
Is there a way to create code short cuts?
For instance, while bug testing, I am forever writing:
<?php die(var_dump($var)); ?>
and figured it would be great to have a shortcut key to automate this. i.e.
"Cmd Option D"
or something similar to dump the pre-defined statement into my code...
Any thoughts on this?
You can use Live Templates:
To define a template go to Settings/Live templates, then select group or create new group of templates and hit the green plus button and select Live Template.
In the abbreviation field type for example vd which will be the trigger for your snippet, define context, which represents the languages this template will be available for and put this in the Template Text field:
<?php die(var_dump($SELECTION$)); ?>
The $SELECTION$ part is a variable which represents current selection.
Now when you are in editor, you can just type vd and hit Tab. That will expand your snippet and put your cursor inside var_dump().
You can event type the variable name you want to dump, select it, hit CTRL+ALT+T, which will show you a Surround with dialog, where you can choose your template. After you select it your variable name will be surrounded with the var_dump snippet.
Another way to invoke a live template is to hit CTRL+J which will show you autocomplete popup with the available templates.
I try to write a link from a first page that will open a second page that includes prettyphoto and automaticaly open the prettyphoto plugin including a third page. Doing that, I've got to transmit a variable from the first link and retrieve it in the third.
Is it possible ?
Yes, it is: If the first an the third website were running on the same server you wil be able to use HTML5 Web Storage or Cookies. Here's an example (HTML5 Webstorage):
// Save...
localStorage.setItem('item', myVariable);
// Open...
var myVariable = localStorage.getItem('item');
I have found the following issue
I added a variable into the link of the first page
mypage.php?my_variable=<? echo $id; ?>
and on the second page, test the presence of this variable to implante an automatic launch of prettyphoto into the jQuery function init :
<?PHP
if(isset($_GET['my_variable'])) {
$id = $_GET['my_variable'];
?>
$.prettyPhoto.open('third_page.php?id=<?PHP echo $id; ?>&ie=UTF-8&oe=UTF-8& q=prettyphoto&iframe=true&width=100%&height=100%');
<?PHP
}
?>
I'm now looking for a full screen prettyphoto auto opening, but that's another problem, the main problem is solved for me.
I have this header that it's fixed across all pages except, the logo. The logo varies a little in color, regarding the page where the user are.
Should we set that on the corresponded controller and call it on the layout.php page ?
On controller
public $param = 'logoimagename';
On layout
echo $this->param
I've heard that Yii by design doesn't favor this, is there any better way ?
I would implement it using an helper function with a signature like this:
function getLogoName($controller, $action, ...){
$logo = Yii::app()->params['default_logo'];
$logo_rules = Yii::app()->params['logo_rules'];
// check if controller and action match any of the logo rules and get the logo name if found; use the default one otherwise
return $logo;
}
The default_logo and the logo_rules are parameters you have to set up in the config files.
In the view files, you could simply write:
echo .... getLogoName($this->id, $this->action->id, ...);
I am trying to update some of my projects old login code, which is a bunch of aspx files with inline VB.NET (no codebehind).
The page in question uses a master page layout. I am trying to expose the header of this master page to the slave pages, which I did by adding a placeholder in the header and exposing it as a property of the master page.
The problem comes in when I try to add a script tag to the header, like this:
Master.Header.Controls.Add(New LiteralControl("<script type='text/javascript' src='http://mysite.com/myscript.ashx'></script>"))
Then i get the error "Only Content controls are allowed directly in a content page that contains Content controls."
I think the aspx parser is seeing the </script> in the string literal and thinking that it is then end of the tag, and giving me that error because it thinks the content following that end tag are not in an block. I can add other tags to the header perfectly fine.
What do you think?
You can escape the / in </script> to prevent this.
Master.Header.Controls.Add(New LiteralControl("<script type='text/javascript' src='http://mysite.com/myscript.ashx'><\/script>"))
Alternatively, you can try
Dim gc As New HtmlGenericControl
gc.TagNane = "script"
gc.Attributes.Add("type", "javascript")
gc.Attributes.Add("src", "http://mysite.com/myscript.ashx")
Master.Header.Controls.Add(gc)