Drupal - Show content on specific page - drupal

Am I able to add the following field to a content type, so that each piece of content I create can be conditioned to a page?
Or is there a module to extend Publishing Options, where by it adds all the pages I have created (just like 'Promote to Front Page')?
If not, why is no one doing this? As a new user to Drupal this seems like it would be a handy operation. (I have already tried this module but it doesn't achieve the results I'm after).
If none of these solutions are available, what would be the best alternative way of doing this?
I've posted this question on Stack Exchange for Drupal but I need a quick answer and there seems to be a bigger community here :D

You should use Context. With Context, you'll be able to manage contextual conditions and reactions for your drupal like Regions.

Have you used Views? it is one of the most common used drupal modules. It doesn't extend publishing options directly but it does replace it in a way. You can say by example put a list of al content-types: your_own_Content_type that have the publishing options of promoted to front-page. then sort them by title, date, what ever you like.
you could also create only one view and create multiple blocks out of it. you have to understand the logic of drupal: if you want different blocks on different pages, you have to create the different pages AND different blocks
create the view for one type of content-type and make one block out of it. put this block on the desired page. All your other blocks are made with the same view, just adjust a condition in your view and create a new block out of it. You should also put all your blocks in the same region, and set the to the right pages
here you can find a lot of documentation if you run into any problems... drupal.org/project/views

Views is the best at creating a slideshow of images or any type of data on your site.
Used in combination with nodequeue it might offer near or the full functionality you are trying to achieve (check this out ... and this too) - but I don't understand your question entirely.

By my opinion Views is too complicated task for much simple request.
There is a few ideas for solution:
Easy way - You can create a specific template file or add some if statments to the node.tpl.php(specific tpl better)
For minor changes - Create a new context with "path" filter and "theme html" reaction, than hide the field by the css
Best but complicated(large usages) - create a new "view mode" and implement the display by new "hook_menu".
~ Almog

Related

Drupal 7: best way to render arbitrary content directly into <body> while keeping what's in <head>

I'm new to Drupal. As I understand a Drupal(7 in my case) page normally would have layers of wrappers around a block, sections, regions etc ... What I'm trying to achieve is to render some arbitrary content directly into "body" with none of the wrapper overheads, while keeping everything in "head". I've researched hook_block_list_alter which allows you to exclude blocks before rendering - which doesn't offer the ability to customize (removing) sections. Then I came across hook_page_alter looks like a good way to go, although I haven't dug too deep yet, still trying to understand the structure of the $page object. I thought about other options such as using the context module to configure sections/zones when requested page url is in certain pattern.
What's "THE Drupal's way" of doing this?
I would suggest you to first try with Drupal's template system and then, if you can't achieve something try with hooks:
https://www.drupal.org/node/337173
So, as you mentioned drupal has layer templates wrapping one around another. Most outer one is html.tpl.php and if you want something to appear in page head put it there. Then, second inner one is page template, which can be different for any content (node) type. But you also have block templates, field templates...
To override templates for specific content type or field or something else Drupal has some special naming convention. So if you name you template some specific way (and clear the cache!) drupal will start use it in that specific case.
Check the documentation for more details.

Drupal - How would I go about creating my own custom view?

What would be the best way of creating my own custom view?
I want to have my page do some specific stuff. For example, I am creating a search directory for different names. But, there will be 3 different types of search functions and I would like to toggle between them with 3 different tabs (each tab goes to a different search function). Would this be all in one view with then 3 blocks or multiple views selected by different tabs? What would be the best way of doing this?
One of the search functions will list all of the names alphabetically and there will be an alphabetical directory at the top that will bring the user to the corresponding letter that they select on the page. I believe that this will have to be a custom view that I will need to create, but I have never done anything like this before.
Does anyone have any good advice as to how I would go about doing this? Do I have to create my own module first? Are there any good tutorials out there that would help?
Thanks!
I'd recommend giving https://drupal.org/project/quicktabs a try. I haven't used it myself, but I know of others that have.
The project page sidebar has links to docu and a demo with some screenshots of config.
If you're going to be reusing almost all of the settings between blocks you'd want to create different blocks displays within the same view and override what you need to.

Create page of blocks only / Create a node of blocks

Sometimes I use a basic page as a place holder for the purpose of creating a node to hold blocks.
So I create a basic page and link it to a menu, then I use the blocks interface to configure certain blocks to display on that page only.
The problem with this approach is twofold. Firstly I don't need the page, but secondly when a user tries to edit the page they're understandably surprised to find nothing.
Is there a better way of creating a node of blocks? Ideally, the more lightweight the better..
Thanks,
Hmm, this solution requires installing another module, but also provides other great functionality such as revisions.
http://drupal.org/project/nodeblock
You would also have to convert all of your old blocks into these new "Node Blocks"
Another option would be
http://drupal.org/project/empty_page

Drupal views: Allowing users to choose sort criteria on node display

I have some nodes I am displaying in a view. They are displayed as nodes, unformatted. I would like the user to be able to choose from some predefined sort criteria ( via drop down list or similar).
So they could pick recently active, most commented, newest, etc., and re-query for new results.
Its easy with tables because you can make the labels clickable, but I do not know how to have similar functionality with a raw node preview display.
Just a thought, from me to me, and for anyone else who may be trying to do this.
An easy, sleezy option would be to just add another page view for each of the required sorts, and provide a link to these other views in the header of each of the pages.
This could also allow for (easier) linking to the individual sorts, so say if you have a sidebar block displaying recently commented nodes, you could adjust the .tpl.php of the block to have the title link to the view displaying the full set of recently commented nodes.
also im pretty sure there should be a way to do this with arguments, but i dont know how
Views 3 supports exposing sort order (just like you can expose filters)
Select the sort order (e.g. add sort by node creation date, then click on the settings for that), you should be able to expose the sort order to the end user. This is just like clicking on the settings for a filter and then choosing to expose it.
Standard views isn't going to support this, so IMO you're best off implementing a custom solution using just a plain old view and this jQuery plugin. You can either do this at the theme layer (the same way as any other JS in a theme) or a custom module (via drupal_add_js() to add the plugin and your bit of custom code). Either way will work, although the custom module has the obvious benefit of being theme independent (and thus more portable).
If you go the custom module route, please consider releasing it as a contrib module on http://drupal.org.

How can I categorize the content types on the Drupal "Create content" page (/node/add)

How can I categorize/organize the content types on my "Create content" page? I'm running Drupal 6.x with CCK. I have a lot of custom content types, and my "Create content" page has become a bit unwieldy, as it lists them all alphabetically. I'd like to organize them by category, so users would see something like:
Create Content
Reports
Report Type A
Report Type B
Events
Event Type A
Event Type B
I don't want to mess with Core, but anything else (custom module, theming, existing module functionality) is fair game. I'm hoping I'm missing something easy, because this seems like an obvious requirement, but all I could find on the Drupal site were these unanswered questions:
Organize Create Content Page
(node/add)
Core: Split create
content page into categories?
You should be able to accomplish this in a custom module, without hacking core.
You'll want to implement hook_menu_alter() to take over the callback function for node/add.
Something like
function mymodule_menu_alter(&$items) {
$items['node/add']['page callback'] = 'mymodule_node_add_page';
}
should get you started. You would then create the function mymodule_node_add_page, and you could use the original callback function as a starting point.
You can also do this at the theme level by overriding theme_node_add_list().
There are some different ways to attack this problem. You can overwrite the old form page or just create a new one with a custom module. Doing that you can in your module do whatever your want.
Another possibility is to do the same thing using views instead. Doing that gives you access to a lot of powerfull features, as you can do anything the views module lets you do. You can create different ways of sorting the content types.
I've heard of many who have used views to make a page like this for the create content page. Which method you choose is up to you, depending on how exactly you want to do this and the data you have associated with your content types, one will be more easy than the other. But without knowing the exact details, I can't say which. I would advise you to start out with views, since you quickly should be able to find out, if you can use it to get what you want.
there's a module that does what you are looking for, Content type groups
I created a sandbox module some time ago which was supposed to do this:
https://drupal.org/sandbox/YaronTal/1260038
The only problem is that I wasn't able to create the admin backend with draggable interface at the time.
I know the issue is old, but just in case someone else has the same problem...

Resources