Override custom content page markup Drupal 7 - drupal-7

Although I've seen some 'clean' answers on this topic here, it still doesn't work in my case, which is the following: being in Drupal 7 with a completely customized theme, I have created a custom content with the machine name cco_product. I want to override the page markup for the page generated for this content type. I have tried, as per the documentation,
page--cco_product.tpl.php in the tmemes folder, based on /module/system/page.tpl.php, but my Hello world on top of this file doesn't show up.
Thanks for help

First, try clean your cache, if did't help, i can advise to look into the an array of templates for your page. Maybe one of your modules or your custom theme overrides array of templates like this:
function MYTHEME_preprocess_page(&$variables, $hook) {
//Add multiple suggestions for pages based on Node
if(arg(1) == 3) { //For node 3
$variables['theme_hook_suggestions'][] = 'page__contact';
} if(arg(1) == 4) { //For node 4
$variables['theme_hook_suggestions'][] = 'page__about';
}
}

Related

Render drupal form in custom template

I'm trying to render DRUPAL content type form in a custom tpl that I created. But its just printing the hidden fields not the actual form.
I tried using drupal_get_form and drupal_render, but nothing works!
Can someone suggest me a link or reference to drupal theming guide?
Am I missing something?
You need to use drupal_get_form and drupal_render on 2 different steps.
$myForm = drupal_get_form('YOUR_FORM_ID');
print drupal_render($myForm);

Different sections in a view in iOS

I want to achieve something like the next image at the bottom. Three sections which I can change touching in each option (Descripción, Video and Afiche). I don't know which UI components should I use according to iOS patterns and components. My workaround to achieve it would be use three buttons and when the user touch any of them I should hide the current view and show other view. Should I do my workaround or do you have any other suggestion? I'm developing from iOS 7. Thanks.
My solution was to use a UISegmentedControl to switch between views. I'm using a WebView and when user change between options I just change the WebView's content.
Assign selector to the UISegmentedControl
[_segmentControl addTarget:self action:#selector(segmentedControlClicked:) forControlEvents:UIControlEventValueChanged];
Method to change between views
-(IBAction)segmentedControlClicked:(id)sender
{
if([sender selectedSegmentIndex]== 0 )
{
[_webViewContent loadHTMLString:desc baseURL:nil];
}
else if ([sender selectedSegmentIndex] == 1)
{
[_webViewContent loadHTMLString:html baseURL:nil];
}
else if([sender selectedSegmentIndex] == 2)
{
[_webViewContent loadHTMLString:desc baseURL:nil];
}
}

Add summary/teaser to Full content in drupal 7

I want to have both Summary and Body in full content view in Drupal 7 but I can't understand how it is possible.
You can edit theme template files to do that. just edit node.tpl.php or page.tpl.php in your theme.
For example get summary in node.tpl.php:
// Load node summary view
$node_view = node_view($node,'summary');
// Get the summary
$summary = $node_view['body'][0]['#markup'];
Or use views to create the content you want.

Drupal - How to add data-attributes to <li> items of a <ul> Menu

This is such a great script called fullPage.js located here: https://github.com/alvarotrigo/fullPage.js
I managed to load the js file and css file and even with the Void Menu Module, managed to call anchor links, but I'm struggling with the data attributes part of the implementation of this cool code! Any help is greatly appreciated! How do I get data-attributes to work in Drupal 7.25? I mean, I need to add them to the menu, so that the html looks something like this:
<ul id="menu">
<li data-menuanchor="firstPage">First slide</li>
<li data-menuanchor="secondPage">Second slide</li>
<li data-menuanchor="3rdPage">Third slide</li>
<li data-menuanchor="4thpage">Fourth slide</li>
</ul>
Just want to add it to the Main Menu in Drupal. Any idea how? Am trying to implement this on my homepage and using the Adaptive Sub-Theme with Display Suite Module installed, if that helps any.
Have added the following to template.php, but it makes no difference at all:
function MY_THEME_NAME_menu_link(&$variables) {
$variables['element']['#attributes']['data-menuanchor'] = substr($variables['element']['href'], 1);
return theme_menu_link($variables);
}
What am I doing wrong here?
EDIT
You can download the sitemaniacs theme here: http://dream-portal.net/dpdowns/MyProblem.zip
You can just download Adaptive Theme from Drupal here and than copy sitemaniacs to your sites/all/themes folder and than just enable the theme and go to your homepage.
There is also a folder called fullPage that is the example of it working perfectly fine without Drupal.
Files to take note of:
/sites/all/themes/sitemaniacs/scripts/custom.js
/sites/all/themes/sitemaniacs/template.php
/sites/all/themes/sitemaniacs/css/example2.css
/sites/all/themes/sitemaniacs/sitemaniacs.info
Let me know if you need anything else, k?
And Thank YOU!!! What I've done is create 4 Basic Pages, and using the Field Formatter Class Module to give the body field a class (when managing the Display) defined as section, than promoted to front page. Than I used HTML within another Node Type and used NodeBlock Module to output it as a menu item within the Menu Bar section of the blocks, with url <front>. Let me know if you need anything else for this, but I can't get it to work using this simple approach. I've tried tons of ways of doing it also, but no go for me. If you find a method that works, or perhaps something is wrong somewhere else, please please let me know.... I'm pulling out my hair on this one.
Have tried straight HTML, and now getting this:
Uncaught TypeError: Cannot read property 'top' of undefined jquery.fullPage.js?mzf0rp:506
scrollPage jquery.fullPage.js?mzf0rp:506
doneResizing jquery.fullPage.js?mzf0rp:889
The first error seems to occur in the scrollPage function on this line here:
var dtop = dest !== null ? dest.top : null;
Looks like dest.top is not defined on .top. Any idea why?
Use the Menu Link Attributes module that will let you add custom attributes per menu item.
for "href" you can use <'front'>#4thpage(front without any “cotation”) in path in menu that you create in Structure > Menus and use the Menu Link Attributes module for other attributes

Completely change the design of a page in Drupal 7

Is there a way I can fully customize a page in Drupal? I don't want the Drupal header or any other HTML generated by Drupal to show up, but I want to be able to access the Drupal functions.
Basically you want a new page template (as opposed to a node template). This does not quite work out of the box in Drupal 7 so there are a few steps:
Step 1
Create a new content type for this specially themed page, call it "special" or whatever...
Step 2
Add this code to your theem's template.php file. (Replace "yourthemename" in the code below with your theme's machine name, that is to say the name of your theme folder in /sites/all/)
function yourthemename_preprocess_page(&$vars) {
if (isset($vars['node']->type)) {
$vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
}
}
Step 3
Create a new page template in your theme folder and name it after the new content type. so for example: page--special.tpl.php and "special" being the name of the content type. Customize away!
Step 4
Clear cache
Step 5
Create a new peice of content using your new content type -- it will be in the design of your new page template.
The end result will be like having a completely separate theme but staying within your existing theme.
Note, I wrote a blog post on how to do this for Drupal 6 but if you read down the comments, there are ideas and links how do this for D7 but basically what I have said here.
http://highrockmedia.com/blog/creating-custom-content-type-page-templates-drupal-php
You can run an alernative page.tpl.php file. Eg. page--front.tpl.php
Not sure it's the best way to do this but it will work. You can strip anything you don't want out of the file so it is totally different to other pages.
Drupal is pretty flexible:
<?php
$json = array(
'body' => 'This is the body of the page.',
'title' => 'This is the page title',
);
return drupal_json_output($json);
?>

Resources