Custom spaces editable from back office in Drupal - drupal

I've got a website in Drupal where in some parts of the site I need some editable spaces to put some banners and edit them from backoffice, (something similar to placeholders in Django).
Is there any module or a way to do this?
Thank you!

There is the block module, which is part of core. Are you using Drupal 6/7/8?
Anyway go into your admin section and look under structure, for blocks.
You can create custom blocks and place them in a region. If you want different regions then you can define these in your themes .info file.
Inside the blocks you can put whatever content you like.

Than you for your help , this did the job:
< ? php
 $block = module_invoke('block', 'block', 'view', "23(block number)"); 
 print $block['content']; 
? >

So, to create a custom (static) block you should go to "Blocks" admin page (Structure -> Blocks) and click "add block page" link. When creating the block pay attention on input format field (bellow "block body" field). If you use some format with filters drupal can (partially) destroy your block code - filter out some content. So, if you are sure that code you are using is safe and don't want it to be changed by drupal select "raw" format.
Every theme has defined regions that it supports. They are defined in:
/sites/all/themes/theme-name/theme-name.info file
So, if you want to change page template and print blocks on your own you must use some existing regions, defined there (it's needed to clear the cache after changing this file).
Region names can also be seen in Blocks admin page mentioned above. On that page you'll see the list of all available blocks and next to block name you'll see drop-down for placing block into some region.
Also, if you edit some block (click "configure" link next to that drop-down) you'll have some extra options to set block visibility (per user, per user role, per page..).
For more advanced block placement use "Context" module which have more powerful features for placing blocks and more:
https://www.drupal.org/project/context

Related

How do I add a module to the text of a basic page in drupal 7?

How do I add a module to the text of a basic page in drupal 7 ?
I need some help. I am having some problems with the drupal donations module
I have done this before on this web site
http://www.arguemax.com/_drupal-7.26/content/donate-using-paypal
But now I can;t remember how I did this.
How do I put this module on a page I am creating? When I go to create the page, there does not seem to be an option to past complex tables or controls on it. I just has a large empty text area to edit the body of the text
I thnhk this is a simple thing.
I was able to find the setting for
Home >> Adminstration >> Configuration >> Web Services == PalPal donation
and that set up the control
So I know it is ready to plop into the page
How do I plop it into the page? I remember there was something like a button bar associated with the text editor for the page that allowed me to add complex items like tables and like this particular module.
As can be read in that module's Documentation, the module creates two blocks.
The steps you need to follow:
Create an empty node of any content type. You can alter the URL and attach it to a menu item as well.
Go to admin/structure/block and find the blocks your module provides.
Hit "configure" on one or both of them.
In each block's settings, in the "pages" section (bottom of your screen) select "Only the listed pages" and enter the url of the empty page you created before.

Drupal page content

I'm new to drupal and reading through docs, but hoping to get an explanation for something.
I have a page called page--type-home-page.tpl.php.
Part of this page prints render($page['content'])). I want to remove something that is rendered as part of the page content from the page, but don't understand where this comes from and where/how to look.
Thanks!
Assuming you're talking about Drupal-7
Well the $page['content'] contains a string, which is a rendered version of what's injected into the content region of your theme.
By default, the only block in this region is the "Main page content" block that is generated by the Drupal core. Many things can generate this content but it always pass through the menu API. For instance, if you're viewing a node, the URL used is: node/12. The node module declares a menu entry for node/%node, this menu entry contains a callback function that will render whatever the module wants to render. The module, then, may use different strategy to render it's content from a simple function to a complex imbrication of templates.
The key to alter what's in the box, sorry, what's in the $page['content'], is to know what is rendered and to understand how it's rendered.
If it's a node, first you want to look if you can achieve your goal through the display settings of the content type. admin/structure/types/manage/page/display: And this is true for all entities (users, comments, taxonomy term etc.) Because this is the first thing the module of these entities will put together when they'll try to render your content.
If this is not enough to achieve your goal, you can look into the module that renders the path to see if it hasn't a .tpl.php. You'll be able to re-use it in your theme. You'll want to copy/paste the file in your theme and edit it.
If the module do not have a tpl file to override, try a template suggestion: here's a list from Drupal.org
Ex: node--type.tpl.php
If all this doesn't satisfy your need, you'll have to dig into preprocess functions; Those functions allow you to modify what's in the variables passed to .tpl.php files. That's a little more advanced and I recommend you to read this previous stackoverflow question/answer
Simply, don't use that $page['content'] which prints all content, but place your custom template code instead and print separate field values where you need them like:
<?php print render($content['your_field_name']); ?>
https://drupal.stackexchange.com/questions/30063/how-to-print-fields-in-node-tpl-php
If you want to do just simple styling, like excluding some field you can use content type display options like mgadrat explained, but if you want to use some complex styling, with totally custom html this solution is easier.

Drupal 7: Add view to content type

I've been making a template for a particular content type, but just ran into a problem: I need to embed a view into the content type.
I am aware this can be done via several different methods, but I don't see one that fits exactly my needs:
I need the view added automatically for all pages of that content type.
Using blocks in a region is not an option, as I want to avoid defining a region in the middle of a page that should only be available for a specific content type.
Translatable label.
Possibility to freely apply a template to all fields in the content type (excluding the embedded view).
I tried doing it via page layout (Panels) and simply adding node content fields and the view to my layout regions, but then I get another problem: I can't style my content fields without doing something that seems a bit over the top:
Currently I have about 20 different content fields in the content type that are wrapped in HTML and styled in my template file. I have a translated label for each of these in the template file. From what I can tell I'd have to add a template for each of the panes containing content fields to add my translated labels and HTML needed to style each field.
I'm not really fond of making 20 templates, 20 theme hook suggestions to get the templates to work and 20 regions in the panel layout just to get a view inserted in the content type.
Am I doing something terribly wrong here? Any suggestions?
You may want to try the Viewfield module or similar modules (search for "view field" or "view reference").
If you are doing something more complex like changing/filtering the view based on some value in your content type, then you may have to use Viewfield module in combination with something else that will help fill in the filter values.
I've never done something like this before so I'm not sure exactly what module combination would work but Rules or Computed Field come to mind as possible helpers.
You have to use "views node field" http://drupal.org/project/viewsnodefield, after installing this module you have to select the "Node content" in the display (like blocks,page). then click the add display. if you want to display the content like this page http://www.richtown.ae/?q=content/arabian-ranches then you have to download the views_galleriffic module and install it and choose the style option "Galleriffic Gallery". You can choose the content type by using the filter in the views.
That's it cheers
i implemented this in my website richtown.ae
if you still unclear please send me the email social#richtown.ae i will reply you & ready to help you we can share information
i am using this module in drupal 6.
I resorted to using the EVA module ( http://drupal.org/project/eva ).
In addition to Woodgnome's answer
Let's say you have a content type named 'Product'
You want to attach a view to it.
Here are the steps using the eva module :
On your view edit page :
Section Displays
+Add : Eva field
Section ENTITY CONTENT SETTINGS
Entity type:Node
Bundles:Product
That's it, going to a node product type will now display the view

Is it possible to add buttons (link) to a view in Drupal?

I am looking to add separate buttons that will be displayed at the top of the view that I am creating in Drupal.
So far all the fields that I have added appear inside of the table as they should. The only thing that shows outside of the table is the search filter above (as it should).
I would like to add 3 buttons(links) in a row that are positioned above the table and below the search area.
Is there any way to do this in Views? If so could someone describe the process? Thanks!
The most straightforward way to do this is through the theme layer. Edit the view, and go into the Header option under Basic settings. There, you can put in your custom HTML for the buttons.
However, as you might've noticed, this places the header above the exposed filters, whereas you want the header below them. To do this, go into the Theme information option under Basic settings, and find the Display output section.
There, you'll see a list of file name hints. Create a file within your theme using one of those filename hints. Then, click on Display output: you'll receive the default code you'll need to put within your newly created template file.
You'll notice in this new template of yours that the $header code block is before the $exposed code block. Just switch the positions and save your template. Back on the view configuration page, click on Rescan template files, save your view, and the header you've added will now be below the exposed filters.

How to embed a node on homepage in Drupal 6?

How can I embed a node on the front page in Drupal 6. The node basically has the image upload field along with title and description. I want it to some how appear on the homepage alongwith a "views" which shows the uploaded images at the bottom.
What I want is to give the users an ability to create content which is right now available at .../node/photo/add. I want to somehow show this box which lets one create content i.e. upload photo with title and description on the homepage.
It's basically just an attempt at creating something like imageshack as an experiment.
I am pretty n00b when it comes to drupal so please be more descriptive.
Jukebox's solution works as a point-and-click method. If you want to do it with code, it's more like this:
create a glue module Handbook | Example Blog Post
turn it on in admin/build/modules
create a menu item using hook_menu() that will become the page
embed the node with node_view()
embed the view (blog post)
in admin/settings/site-information set your page to the
You can use the Node Blocks module to, well, turn your node into a block. This means that you can go to the /admin/build/block page and place your node in a particular region.
After installing the module, edit the Content Type of the node you want to turn into a block. Under Workflow Settings, Available As Block, choose Enable.
Now you can go to /admin/build/block and you can see some new blocks. Just choose the one you want and place it in the region of your choice. You can also configure that block's visibility settings from there as well.
If your planning on having a more complicated home page at any point in the future I'd highly recommend using Panels to do this. It will allow you to arrange your front page with views and nodes in a grid method.

Resources