Over the past several days I've been immersed in hacking xtemplates. My goal was to assign templates based upon sections of the Web site. My first inclination was to assign styles based upon the vocabulary of the site, later I decided that for my purpose it would be better to assign styles based upon terms.

I've gotten as far as:

  1. Copying Xtemplages and renaming every reference
  2. Creating the necessary functions to access the "terms" stored in the DB. (wish that I had known about some of the functions in taxonomy.module before hand)
  3. Generating new forms in the theme manager [ /admin/system/themes/mxtemplate ] to assign specific templates to each term.

Where I was headed:

I was hoping to somehow pull the term (taxonomy) of the current page, and match it to the data that I had already collected. If there was a match, I was going to give the page a different style sheet. But I'm not sure if this is even feasible. I realized this when I started poking around more in the xtemplate code. Then I started looking at the URL's that Drupal generates and I realized that you can have multiple taxonomies displayed at the same time. Obviously I'm struggling to understand the different components of a drupal page that gets rendered to a browser.

From here I started thinking about assigning templates based upon path aliases. For example, if you create a path alias /events-calendar you could assign a theme to that path. But even this approach has it's limitations.

Back to the drawing board:

Questions

  1. Could someone explain to me the different components that a rendered "Web page" consist of? (e.g. Node, Block. etc.)

    I'm confused about what's a node, and what's a page. It seem like everything's a node with other nodes and blocks nested within.
  2. How do you grab information about the current page that you're on. For example, if I wanted to know the taxonomy of the current node how would I get that information. And if I wanted to know the current path or URL how would I ask Drupal for that information?
  3. Does anyone have suggestions for a different approach for assigning multiple templates?

Posts that I've written while trying to hack xtemplates:


A thousand thanks to those of you who have been answering my newbie posts over the past few days :)

Comments

SupaDucta’s picture

Could it be possible to assign at least a different CSS to a vocabulary? That way at least different sections of the site could have a different appearance...

I am also a newbie in Drupal and have been banging my head for some time on this, without success...

strayhand’s picture

My understanding of Xtemplate is the following:

The _settings() function scans the xtemplage directory for styles. By default Xtemplate comes with two styles (default, and pushbutton). You can select which style you want on the admin page. Xtemplate stores your selection in a $global variable which it then passes to the functions that it uses to render (nodes, comments, blocks, etc.).

Within each style folder (e.g. pushbutton) there is a xtemplate.xtmpl file which is nothing more than HTML code with sustitution tags. The xtemplate application replaces the substitution tags with the actual content. The link to the CSS file (xtemplate.css) is contained within the actual xtemplate.xtmpl file.

Your suggestion of switching the CSS based on the site section, would require a change to the link from the xtemplate.xtmpl file. I think this would probably require as much scripting as pointing xtemplate to an entirely different style folder. Also, switching just the style sheet might be easier with a different theme engine such as chamelon or phptemplate.

The advantage of pointing xtemplate to a new style folder is that you could also change the HTML mark-up within the xtemplate.xtmpl file. I for one am in favor of this because it allow you to really change up the content.

Ultimately I would like to push this hack to xtemplate one step further by separating the templates and the style sheets. In the admin page you could select a template and a style for each section. Then you could mix up different templates with different style sheets.