Im currently working on a Django CMS project and see different placeholders on the pages - TOP, LEFT, CENTER,RIGHT, BOTTOM, HIDDEN.
I know how the plugins work but not sure how to have these multiple placeholders on the page. Anyone could direct me in the right direction would be helpful.
There are two types of placeholders in django-cms. Standard placeholders, and static placeholders.
The standard placeholders can be added to templates and will be made available on all standard CMS pages using those templates. These placeholders can hold different plugins for each page they're used on.
Standard placeholders are quite simple, and added to templates with {% placeholder "section_line-events" %}.
Static placeholders provide a single placeholder for the whole site, identified by a given name. For example, your footer would likely be a static placeholder so that it's the same on all pages.
Also, if you've got applications hooked in to CMS, the templates in those apps needs to use static placeholders instead of standard placeholders if you need to allow the use of plugins within your apps.
For example, if you've got an application which you add some default content to, but want to make editable by your user/client you could add a static placeholder;
{% static_placeholder 'my_app_placeholder' site or %}
Default text for this placeholder.
{% endstatic_placeholder %}
Related
I have started learning wordpress recently. I have started from version 5 with this new Gutenberg editor which introduced Blocks. I am little confused regarding difference between this new Blocks concept and old Widgets.
Starting with a Blocks: they appear on page creation and can be added to page, there is nice documentation on wordpress webpage: https://developer.wordpress.org/block-editor/tutorials/block-tutorial/ a lot of stuff related to new blocks.
Everything is fine, but Blocks can be added only to page content and not into areas like: sidebar, footer etc.
For changing content of sidebar,footer areas we need to access Appearance->Widgets area where we can add multiple widgets to specific areas. Also for new Gutenberd Page Builder there is section called widgets available but with less number of widgets than under
Apperance->Widgets section.
Im totally confused. Could someone explain what is the difference betweemn Blocks and Widgets?
Why for areas like sidebar/footer we can add only widgets and editing footer is under Widgets menu?
Why only part of widgets are available for Gutenberg Page Editor
What should i do to create reusable code snippet(some html/css/js logic) to be reused on a page? Should i create a widget and somehow include it to widget section for Gutenberg or maybe i should create this new concept of Block? But i will not reuse my block in footer/sidebar section...
Are widgets something which will gonna die soon in wordpress world and will be totally replaced by Blocks? I remember that in previous version we were able to add widgets to page using some kind of shortcodes, so any widget we want? Is it still possible?.
I will appreciate any comments on that.
The Block Editor is so far being used only to generate "content". In the world of WordPress, that normally very generic word has a very specific meaning: whatever is returned by the function the_content(). Usually it's simply all the text and media input on the edit page of a post or page, though that can be modified by filters. This content is entered either in the classic editor's text box or (now) in one or more Gutenberg Blocks.
Widgets, on the other hand, display content outside the main content, in widget areas that your theme has located outside the main content in headers, sidebars, footers, etc.
I suspect you already know much of this. As to your question about code snippets, the simplest way to re-use code is through WordPress shortcodes. Register your shortcodes in functions.php or in a plugin; enable them in your theme; then use them anywhere. There is now a shortcode Block, by the way, for placing recurring content into main content.
I'm a WordPress developer who's been tasked to create a temporary one-pager to a Drupal site. The client would like to have a simple front page with a logo and 4 external links until their new site is ready. Normally I'd just make a simple index.html page with some CSS and call it a day. But in this case they need some of the sub-pages from the Drupal site to continue to work.
Had it been a WordPress site, I would have just created a new template file and a new page inside WordPress, and made that the front page. But as I have zero experience with Drupal, I don't know if you can do the same thing here.
What is the easiest (quickest) way to make a simple splash-page as the front page, while having the rest of the drupal site continue to work? The splash-page should ignore all CSS and JS from the original theme — preferably have a completely independant section fromt the rest of the site.
In Drupal 7 you have few "levels" of templates. First you have "most outer" template html.tpl.php It contains html head and it is usually common for all pages.
Then inside that html.tpl.php you'll include page.tpl.php. That one should again contain some common page elements, as header and footer, but again, if your design requires that, you can have more than one page template.
Page template will include node template. In drupal you have 2 basic content (node) types but you can create many more of them. Basically for every different page layout you can create new content type (but there also are lot of different ways to achieve the same thing).
Basically you should create new content type called i.e. "splash" (machine name!). Add fields to it if they need to be back-end editable.
Then you should create new template file for your content type. Name matters, so you should call it node--splash.tpl.php . You can find and copy to your theme existing node.tpl.php and change it to your needs.
Keep in mind that when ever you add/remove new template file you have to clear the cache so drupal would scan theme directory, notice and start using new templates.
And if you need also different page template for you page you'll have to put some code into you tamplate.php file:
https://www.digett.com/insights/overriding-page-templates-content-type-drupal-7
Drupal template engine design an specific file name for override front page.
You can create the file html--front.tpl.php, and this will be used only for the front page without touch any other page. You can page here your custom HTML and reference css/js.
If the page you need share common styles with the rest of the site, I would recommend to instead override page--front.tpl.php which is basically the content of the page without the tags
For more information here is a link https://www.drupal.org/docs/7/theming/howto/customize-the-front-page-template
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.
For all pages, Wordpress give us a default page template : page.php. That's clear and simple, by default all pages use this template. Then, Wordpress give us a page template system, and when we speak about template we think reusable so we think about page layout template.
For example : full-width, page-width, sidebar-left... You specifie the template to use for each page, it's ok.
But when you begin to work on a more complex web site, your content will not be a simple post (page type) inside a page template anymore. For a reason or another you have to use another feature of Wordpress : page-slug.php. Before, of course you can try to do shortcode for everything you develop, include specific plugins only for your complex page etc but ONE DAY, you will have no choice to use this page-slug.php.
Here comes the problem : the content is "more specific and complex" but you still need to use your layout template, and you can't... Of course, you hate duplicated code so you don't want to just "copy" your template inside.
If we really want a specific page, we use the page-slug.php without a page template and it do the job. Then...
Why Wordpress don't consider the page-slug.php as pure content when (and only when) a page template is specified ?
Am I missing something ?
Thanks
I am trying to migrate my site to Drupal and I am confused about themes and templates. The look and feel of the pages in my current site are completely controlled by template files and CSS. How does it work in Drupal?
In drupal, a theme handles the appearance of the site and a template handles how your content is rendered.
Think of it like this: the template is used to render the content, then the theme is applied on that content.
Edit: So, your css files live with the theme in drupal, and have nothing to do with the templates.
In Drupal, a "theme" is just a special type of plugin that bundles together any number of templates (to control how a given piece of data gets rendered to HTML), CSS, JS files, images, and so on.
So, there is a single "template" for your oveevral page markup, a single "template" for how a sidebar block is rendered as HTML, and so on. All of them, bundled together and named, are referred to as a theme.
Look at it this way: It's possible to create a theme that has no templates. Such a theme would have CSS files that override drupal's default CSS files. Using such a theme would create a website that looks almost exactly like Drupal's default site, except it would have different colors, fonts and so on.
But if you want to change the positions of items on the page, what kinds of items are on the page and so on, you have to override the default templates by adding some of your own to your theme. These new templates let you alter what information Drupal displays and what kind of HTML Drupal will use to display it.
For example, say I want to clone StackOverflow, but I want to do it with Drupal. First thing I would do is create a new content type (call it a "question") that is just like a story but has extra fields to track voting and so on. Drupal's default templates won't know about these extra fields, so they won't display them.
So, what I do is I go into my theme and I add a new node.tpl.php file. This new template is just like the standard one, except I can add code that says "if this node is of type 'question', insert the voting gadget to the left of the body."
Does this help?
A theme is made up of a collection of template files. block.tpl.php, node.tpl.php, page.tpl.php are all template files which when combined with your CSS, JS and images produces a theme. In addition a themes can be inherited. A theme can be created with just CSS and no additional template files by inheriting from an existing theme, in which case the template files from the parent theme are used.
Another way to look at it is a theme is what you see and the template files are responsible for generating the markup.
I hope this makes it a little bit clearer.
I'm confused...
The first answer says that templates and themes have nothing to do with each other, while the second one says themes are just collections of answers.
Which one is right?
Drupal is having a template based theming system. You can define your own regions in page and can arrange the content according to that . There are some default template file such as page.tpl ,block.tpl ,node.tpl which are displaying different kind of contents .
You can write your own template file as needed for eg if you need to alter the display of user registration form or login page you can create a tpl file for that and have to redirect the data to that tpl file. You can add the css or js to these templates using drupals apis. This redirection has to be done in the themes template.php file
A theme is comprised of css, js, images, and template files. Each theme may include multiple template files.
Additionally, themes can be inherited, and a subtheme's template files could override the template files of its parent theme.