Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Basic drupal model / concepts

I'm migrating a site from a proprietary cms (reddot) to drupal. For all its flaws, reddot has a very simple yet flexible model:

  • templates consist of markup with placeholders for variable content
  • every piece of content, from a full page, to a shared piece of sidebar content, and even a single image can be built from a template, if an appropriate one exists

My first impression of drupal is: woah, this is complicated! Rather than three simple objects, now i'm dealing with nodes, pages, blocks, regions, views, panels, etc. What is the simplest way to recreate the template/content/placeholder model that i'm familiar with?

like image 697
Bobby Jack Avatar asked Dec 29 '22 01:12

Bobby Jack


2 Answers

Reddot uses a rather well architectured MVC-alike system. In addition, from my limited experience, Reddot follows the there is only one way to achieve Foo-philosophy.

Coming to Drupal, especially as a frontend-developer you will be dissapointed, lose a lot of hair and probably curse a few times when you realise everything has to be done all over again.

Coming to Drupal you will love the gigantic amount of (unfortunately unorganised) documenation and its flexibility and enormous amount of new posibilities.

When people come from properly architectured systems into Drupal, I advice them to do one thing: become pragmatism-exstremists. Don't (ever) try to make things proper, clean or well-thought out. You will only be able to do that once you truly grok Drupal. And that only comes with a lot of experience. Just fiddle untill it works, close the code and never look at it again.

First thing you will need to learn, is Drupals PHPTemplate engine, which is rather different from Reddots, but has a lot of similarities. Where Reddot uses RenderTags, Drupals PHPTemplate uses plain old PHP.

<%!! Context:CurrentPage.Template.Name !!%>  

becomes

<?php print $name ?> 

And yes, $name is entirely globally scoped. Remember? I told you to be a pragmatism-extremist. Don't even think about namespacing, object scoping and such.

Want to know what variables you have available? Just do a <?php print get_defined_vars() ?>.

Want new variables in your template? You need to preprocess them.

Want to change, alter, strip or modify existing variables? You either need to preprocess, or template override or even write new modules that make new or different variables available? Knowing which to choose, when to preprocess, when to create modules, when to override, when to implement hooks to alter stuff is experience. Drupal has never thought that out clearly, there is no general rule or best practice, other then the last eleven times that Foo-concept did not work out, maybe Bar proves the best.

like image 190
berkes Avatar answered Dec 31 '22 14:12

berkes


Drupal's templates are similar to what you describe of reddot, but there are probably more options and they can be nested. To get a good sense of how the templates work together download the Theme Developer module and watch the associated screencast.

To get a sense of the "placeholders" you can use in a given template, visit the api.drupal.org page for the template file or check out this Drupal 6 Theming Cheat Sheet.

like image 21
Matt V. Avatar answered Dec 31 '22 15:12

Matt V.