I've created for the first time a forum in Drupal. I've added some nodes (posts).
I would like to customize the order of the node components.
For example see this image: http://dl.dropbox.com/u/72686/forum-node.png
I would like to move the "Previous post - Next post" to the top, and move "Login to answer" on the bottom etc..
Is there any Drupal setting to do it, or I should work on the template ? Which is the template for forum nodes ?
Otherwise I can do with a module hook, I know how to change the forms components weight, but I dunno how to change the layout of the nodes.
Thanks
Whenever you want to change to markup (HTML), you generally have to do it with theming. You wont find modules that give you options to move things around. That just too much work, and you can never make every one happy. Instead they set up the module to be overridden and provide a sensible default that most can use.
So with the Drupal theme kit, you generally have 3 options.
Override a theme function.
Override a template.
Create a preprocess function.
In this case, it looks like, there is a master template that organizes the initial post, the answers and the login option. You can find out if this is the case and how the page is created with devel themer. It's a good tool to help find templates and theme functions when you're new to Drupal theming.
Related
So I'm getting into theming in drupal 8. It's my first drupal version I have worked with. I know WordPress pretty good, and all programming languages.
Here's my question now:
Is it true when making a custom theme in drupal, you don't have to code that much?! I don't really understand, I've made my basic theme, added some twig files, modded them, ... but the most of my work is (/will be) in the block, view, structure, ... department. Am I doing something wrong?
I've been trying to catch up with reading tutorials, but this question isn't really answered anywhere...
For example, if I wanted to add a header image to my theme, I just have to make a custom content type and edit the view, block, ... to add this? No coding required?
Thanks for clearing this up for me!
Drupal uses kind of nested templates. Like most outer is "html" template, which contains page head, includes js/css files and similar. It also includes next inner level, called "page" template. It usually contains common elements for all pages, like header (logo, menu, language switcher...) and footer. Then yet inner is template file specific for every page. If page is a node then it's node template or if it's a view, then view template... You can also have more inner templates, i.e. for specific block...or field.
https://www.drupal.org/node/2354645
Of course if you have different content types or block you can also have different templates for every one of them. They are set by following naming convention. So if you name it correctly, clear the cache and Drupal will star using your template instead of default one. So you can, but you don't have to override default templates.
Also when you crate your theme you can start from scratch, but you can also inherit some existing theme and just override some files.
i just started using drupal and here is a thing which i simply dont understand. so im writing my own theme derived from the default themes. i enabled the image module to also have featured images for basic pages - so far so good. now in template.php i use the preprocess_page hook to get the image to put into a sort of banner above the page content but .. the node object is not in the first parameter (of the function= but only for the front page?! on all other pages i see the node object. can somebody explain that to me maybe? or does this sound like some self produced thing. i tested the bartik theme and i could reproduce this behavior so i wonder why
thanks
I'm developing a theme for wordpress and would like to know the best way to show highlights on the home page.
Examples:
I thought two ways:
Custom post types -a custom post "highlight" with metabox for image, text and link.
Theme Options - a page with options for each box.
What is the right way?
Neither. What you want can be achieved using either Wordpress' core functions and/or Custom Fields. Consider using Custom Meta Boxes if you have a client that requires a more intuitive setup, or installing something like the Types Plugin to do it for you.
This will allow you to attach your own variables to given Posts/Pages.
To gain access to a post's Custom Fields, click the Screen Options button at the top of the Post Editor to enable Custom Fields.
Personally, I would Enable Support for Thumbnails for your Highlights image, use The Excerpt for your Highlight copy, and use either The Title or a Custom Field for the heading.
This way, you can keep all your eggs in one basket rather than overcomplicating things with Custom Post Types or Theme Options Pages.
Look at the Plugin "Ether Content Builder"
You could use either of the methods you've suggested. In my opinion getting involved with lots of meta boxes on one specific page template for this is a total waste of time - there is only an image, a header and an excerpt linking to a post/page. Three posts (whether custom or not) will handle that with featured image, excerpt and the page/post title.
I also think doing a Custom Post type is too much just for three posts on the homepage. If you go the posts route just create a new post category called Home Highlights and put your three posts in there, pull them in via a custom loop built on WP_Query.
Yes you can go the Theme Options route too. If it's the client updating the site then it can look quite professional this way, I've started using a plugin called Options Tree after it came integrated with Super Skeleton, it makes it very easy to build your custom theme options which work just as well too.
A matter of opinion really, rather than a hard and fast 'this one is definitely better'!
I am a newbie in wordpress and I was given the opportunity to edit a certain plugin which is MarketPress, but then I had hard times dealing with it since I'm new to this thing and I don't know where exactly to go, I would want to edit an included dynamic_sidebar but I can't the file on where to edit this. Please help me. :(
Thanks.
Not sure of your level of understanding so forgive me if this is over-simplistic.
The sidebar content is driven by widgets, which is controlled from the Widgets admin panel. The only thing about a sidebar that you should be able to edit by messing with its definition are the wrapping markup for the whole widget and for the title, along with the sidebars name and description. The last two only effect text that shows up in the admin Widgets panel.
However what I describe above is not found with the dynamic_sidebar() method, rather with the register_sidebar() or register_sidebars() methods. These 'define' the name and settings for a sidebar. The dynamic_sidebar() method is the used to implement the sidebar by passing it that sidebars name.
The sidebar is then populated with widgets via the admin Widgets panel.
Typically sidebars are registered from within the functions.php file of a theme, but if a plugin contains templates there no reason why it couldn't also have its own sidebars. As for where the register_sidebar() function is being used in your plugin specifically, I couldn't say. Just search through it using whatever IDE you like, or grep if your comfortable with it.
Hope this helps.
So I have my parent theme and my subtheme both enabled in Drupal 7.
I've specified in the .info of the subtheme that the base theme is the parent theme.
Once I create a page, how do I tell that page to inherit my subtheme?
Any help would be greatly appreciated.
EDIT:
So what I want to do is create several new pages (about 20) that are going to follow the same template file as the rest of my Drupal site. However, they are all going to have different background images, link colors, and heading styles. I figured the Drupal subthemes would let me create a page that inherits the main stylesheet, but lets me modify it as needed for the new pages. Sounds like that's not what subthemes are for.
Thanks to Matt V:
Subthemes allow you to use an existing theme as the starting point for creating your own custom theme.
I may be wrong but if you want to implement different themes on different pages, it sounds like what your looking for is "hook_custom_theme", it's pretty straight forward, basically you just add:
function mymodule_custom_theme(){
//Some custom logic here
$node=node_load(arg(1));
if($node && $node->type=="my_custom_type"){
return 'my_custom_theme';
}
}
your return value must be a string that equals the machine readable name of the theme you're switching to...
re-reading your post, you may want to look into the template_preprocess_html and template_preprocess_page functions. Inside of these functions you can set and alter your template variables, i.e.
$vars['styles']=drupal_get_css();
once you've done that you could easily swap out css tags with a little bit of logic, this method would allow you to only use one theme with multiple css files....
to activate a subtheme, you need to enable it and set it as default.
The subtheme (or any theme for that matter) is for the site as a whole. To theme an individual page you could create a template for that specific page, or use the Panels module - there are many ways to skin a cat in drupal.....
here is some more info Drupal 7 theme system changes
By using themekey module you can achieve this
Refer http://drupal.org/project/themekey
To have your theme activated site-wide and used as default for ALL pages, you need to go in admin/appearance and activate your theme, and then click on the link beside the theme "Define as default".
To have your theme used on one specific page, that would be a bit trickier to do, just clarify if that is what you really wanted.