开发者

Basic drupal model / concepts

开发者 https://www.devze.com 2023-02-10 16:33 出处:网络
I\'m migrating a site from a proprietary cms (reddot) to drupal. For all its flaws, reddot has a very simple yet flexible model:

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?


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.


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.


Another one bites the dust.. ;) Let me know how you go with the migration Bobby Jack. I think for the content you might be able to create an XML variant in the CMS and export everything to re-import it to Drupal.. On the Drupal note: Once you get your head around the concept of templates being able to inherit/being overwritten it's easy. It's like a set of pre-assigned content classes in RedDot which can change to render them in a different layout. Similar to the "replace content-class" functionality.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号