I'm a newbie to CakePHP and i'm trying to modify the login.ctp so that it would go to a different DIV tag. I already have a default.ctp layout placed in /views/layout but i don't want the menus to appear on the login page when you bring up the site. How do i go about doing it?
Thanks,
Lyman
make a login layout that has no menu, and in login(), set $this->layout= 'login';
in login function, save variable:
$this->set('nomenus', true);
in default.ctp check
if( empty($nomenus) ) {
... menus ...
}
Related
I want to remove the sidebar from the specific page and all its subsequent pages in Drupal 7
My code is mention below.code is in mytheme_preprocess_node(&$variables) function
if ($variables['type'] === 'project'){
$node = $variables['node'];
if($node->type=='project'){
//print_r($node);
echo $node->type;
unset($page['sidebar_second']);
}
why don't you create a tpl file for that specific content type and remove the sidebar from there ? just an idea
Try restricting the block in Blocks UI or with the Context module.
You can restrict that sidebar content in admin panel itself. login as admin and configure that sidebar block to display only on perticular url.
I'm trying to set a variable in a reveal modal with CakePHP.
The reveal modal i'm using is with Zurb Foundation
I have to generate a code and display it.
I have a HomeController with a generatecode() function.
In my Home.ctp I have a div with reveal modal (cf. Basic section here)
I have also a link button generate with that code :
echo $this->Html->Link('Unlock Link', array('action'=>'unlockpwd'), array('class' => 'button small', 'data-reveal-id' => 'modal_unlockpwd'));
Here is my action code :
function unlockpwd() {
$this->set('code', $this->Function->generatePwdLock());
$this->redirect($this->referer());
}
And in my Home.ctp, i just display $code in the reveal modal but i get an undefined variable error.
I think it's because i display the modal before i set $code.
How can I solve this problem ? I tried the setFlash, it works but the reveal modal seems better for the user.
Thanks for your help :)
You set 'code' as a variable and redirect away from the page so the variable is lost. Solution would be to do:
function unlockpwd() {
$this->Session->write('Code', $this->Function->generatePwdLock());
$this->redirect($this->referer());
}
where you want to see it:
echo $this->Session->read('Code');
$this->Session->delete('Code'); //if you want to show only once
I am new to cakephp...I have a user add form (add.ctp) and would like to display this form in my default layout (default.ctp)
Aren't Elements the thing you're looking for?
http://book.cakephp.org/2.0/en/views.html#elements
In your default layout there should be a line:
print $this->fetch('content');
If this line is there than cake will automatically include the needed view based on the url and routing.
I have a sidebar defined in my main layout which most of the time will display the login form. After the user is logged in I need to remove that form and replace it with user data. I also need to change that sidebar when viewing the support section to show the sub-sections.
Do I need to move the element loading to each view or is there another way?
Thanks in advance,
Denis
Bottom line is you're gonna need an if($supportpage){} elseif($loggedin){} else{} block. If you don't want to put it in your layout file you could create an element for each option and then set() the correct one from the app_controller:
if ($supportpage) $sidebar = 'support';
elseif ($loggedin) $sidebar = 'loggedin';
else $sidebar = 'notloggedin';
$this->set(compact($sidebar));
And then put $this->element($sidebar) in your layout.
How to generate 'a href="javascript:void(0)"' like link in CakePHP?
I make an application, the content will insert into the editor textarea when user click a list of image. I add a class to these images and write some code in the javascript file. Everything is going well.
But the link of the image is a URL address, but not 'href="javascript:void(0)' like URL. Anyone could tell me how to make it in CakePHP?
Thanks in advance!
<?php
echo $this->Html->link(
'/path/to/image/',
'javascript:void(0)'
);
?>
You can either set a path to the image or use the Html helper to generate the image tag code. The second parameter will set the href.
Don't believe there is any dynamic way, however when you are creating your form element you can set it in the options array 'href' => 'javascript:void(0)'