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.
Related
I need to add a paragraph of text near the top of the user profile page found at /user, this is page you are initially taken to after login.
I'm not fluent with Drupal, and I can't find any answers online.
Could any advise how I can add text to the user profile page?
you can also add a block to the "content area" to be shown below the user profile (restricted to user/* pages). In the block you an use short PHP snippets.
In a custom Drupal module you could use hook_form_FORM_ID_alter(), this will let you change the user profile form, where you could attach a div element that will hold the paragraph text you wish to insert to the page. You will also give weight to your div, so that it is displayed on top of the form.
Here is a code snippet:
function custommodulename_form_user_profile_form_alter() {
$description_html = '<div>Lorem ipsum...</div>';
$form['description'] = array(
'#markup' => $description_html,
'#weight' => -10,
);
}
I was trying create a left side menu bar. I used the following code in my layout file Templates/Layout/admin.ctp
// Create the sidebar block.
$this->start('sidebar');
echo $this->fetch('sidebar');
echo $this->element('sidebar/left_menu');
$this->end();
But the sidebar is not showing in the page. The Left menu sidebar file is located at Templates/Element/Sidebar/left_menu.ctp
Any help will be appreciated.
There are two things I can point out:
The default directory for templates is src/Template and not Templates
As you are starting the block, fetch('sidebar') will return empty. Try putting it after the end of the block
// Create the sidebar block
$this->start('sidebar');
echo $this->element('sidebar/left_menu');
$this->end();
// Display the sidebar
$this->fetch('sidebar');
I'm new to Drupal CMS. Here I want to set front page link for main menu item. It set that for front page link as per Drupal guide. But, it gives an unexpected result example.com/.
Is there any way to display any front page or blank for my main menu item eg: example.com?
Note that I'm using a custom theme.
By default Drupal doesn't add slash if tag is used. You can try checking your rewrite rules.
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.
I've been trying to get this to work for 4 days now, with no luck.
I have a very simple jquery mobile app.
The app has a header, content and footer.
The footer is being generated dynamically on the 'pagecreate' event because it is always the same and I don't want to have its HTML in every page.
So I do something like this:
$(document).delegate('[data-role="page"]', 'pagecreate', function (e) {
DrawHeader($(this));
DrawFooter($(this));
SetFooterEvents($(this));
SetActiveFooter($(this));
});
DrawHeader() and DrawFooter() simply prepent the header div to the page and append the footer div.
SetFooterEvents() sets the onclick events of the footer navbar buttons and SetActiveFooter() is SUPPOSED to set the ui-btn-active to the current active footer link.
To do this, I've added the data-active-footer attribute to the page div and the data-name attribute to the navbar elements. I'm searching for the current element according to the data-active-footer in the page and apply the ui-btn-active class.
function SetActiveFooter(page) {
page.children('div[data-role="footer"]')
.find('a[data-name="' + page
.attr("data-active-footer") + '"]').addClass("ui-btn-active");}
So far so good.
Now, say I've changed to a page and the navbar is lit (it has successfully recieved the ui-btn-active class), and I'm clicking on the previous page, the lit item in the navbar doesnt change back!
If i click on the the page again (ie: changed to second page [corrent lit], changed back to first page [second page is still lit], then clicked on first page again) it does light the navbar button.
What I found out was that jqm also changed the navbar of the previous page when I'm changing the navbar of the current page in the 'pagecreate' event.
I've tried to overwrite this behaviour using the 'pageshow' event, that is, trying to apply the ui-btn-active class to the current element in the navbar but the problem is that $(this) and e.currentTarget objects in the 'pageshow' event DO NOT CONTAIN THE FOOTER ELEMENT!!!
$(".ui-page").live('pageshow', function (e) {
alert($(this).children('div').length); // returns 2!
alert($(this).children('div[data-role="footer"]').length); //returns 0
alert($(e.currentTarget).children('div').length); // returns 2!
alert($(e.currentTarget).children('div[data-role="footer"]').length); //returns 0});
Any ideas?!
Thanks.
Before delving into more detail, please try adding .ui-state-persist together with .ui-btn-active
This makes sure active buttons stay active when you changePage and the footer is the same. Also make sure, all your footers have the same data-id attribute.
On a sidenote: check the latest blog post about upcoming features for jqm 1.1 - it will include a fetch link utility, which allows to ajax-update portions of a page. So you could use this functionality to grab and insert a footer on every page. I'm trying the same right now with a login form, which I need on every page.
Have you tried "ui-state-persist"?
<div data-role="navbar" data-iconpos="top">
<ul>
<li>Home</li>
<li>Favorite</li>
</ul>
</div>
I still dont know why but jqm moves the footer from page to page, eventhough I assign a new footer to each page.
Maybe because I set the same ID to all of them.
Anyhow, I used this workaround to solve the problem:
On the 'pagebeforeshow' event, I set the button I want active to all the footers in the documents. I've set a special data-name attribute to each navbar button, I give it the 'ui-btn-active' class after removing it from the rest of the items.
var $footers = $(document).find('div[data-role="footer"]');
$footers.find('a').removeClass("ui-btn-active");
$footers.find('a[data-name="' + page
.attr("data-active-footer") + '"]').addClass("ui-btn-active");