tags:

views:

85

answers:

4

I have been trying to figure this out for days. Hope someone can help.

I am implementing a new theme for a site. I added the html to a page.tpl.php file, populated it with the appropriate variables, and it works OK so far.

It consists of a header, footer, and a left and right div. The left div successfully displays the output of the $content variable.

The right div is supposed to show a flash video followed by two images, all displayed vertically, which vary with each page. And here I'm really stuck.

How do I go about adding these?

A: 

Depending on how much you want to program you're probably going to use blocks. I you don't want to program a lot create a bunch of blocks with each image/video combo you want. If you don't mind programming you can create a block in a module with all the code necessary to pull up the right images/videos on the right page.

But the most basic way will be at /admin/build/block/add then associate the block with the right area on /admin/build/block. You can control which pages these blocks wind up on on the block edit form.

This link may be handy for you.

Chuck Vose
A: 

The first thing you need to do is add the files to each page. You can do that with CCK and filefield.

Once you have the files in the pages, you need to get them out of $content, where they'll show up by default. You can do this by turning the fields off under Display Fields in CCK.

Now that the files are no longer in $content, you need to put it in something else. Most themes have a $right region you can use for that. So put $right in your right div. You can populate $sidebar with blocks, so you need a block containing the files for the given page.

You can make this with Views. Create a new node view, add an argument for node ID, and give it a default value from the URL. This basically tells the view to look at the current node/page. Under Fields, choose "Content" and find the file fields you added with CCK. Finally, add a display of type "Block." Save.

Now you have a block with the files on the current page, and you have the $right region on every page, so just go to the Blocks admin page and put this block in that region.

Scott Reynen
I am trying for a different set of images for each page.
John Rand
You say "You can populate $sidebar with blocks, so you need a block containing the files for the given page." Does $sidebar also go in page.tlp.php?
John Rand
Sorry, I should have said $right, not $sidebar, as that's a more common region in themes. You should use whatever region you have in your theme, which you can see on the blocks admin page. And yeah, you should put that in page.tpl.php.
Scott Reynen
Scott, thanks for your help. I think I'm almost there, but I'm finding the Views interface tough. So far, I have Created a new node view, added an argument for node ID (Node: Nid). You say "give it a default value from the URL". Where does this go? Also, under Fields/Content, I added the field I added with CCK. The format is "Generic files". Is that OK? Also, "add a display of type 'Block'" - above the list of Basic Settings, it says "Block Display the view as a block. ". So I guess that's done. So far, I only see the label "image_1", but I think I'm really close.
John Rand
A: 

Scott and Chuck have already provided the details for this question, but I thought I would just point out scenarios when each answer may be appropriate.

If you want those video and photo blocks to display on pages which are NOT node pages, then you will probably need to go with a solution similar to the answer Chuck provided.

Most likely, it sounds like you do want the the video and photos to be related to the content shown on the left. If that is the case, then Scott told you what you need to know.

MikeyLikesIt
A: 

One final piece to the advice from those above was the following:

  1. "How (where) do I set it up so that the view recognizes that it is on Node 3 and displays only the images for Node 3." -- you can do this by clicking on the settings for the Nid argument in Views. Under Action to take if argument is not present: choose Provide Default Argument. In that, choose Node ID from URL
  2. Position your block in the appropriate region (left sidebar, right sidebar etc). Make sure the visibility settings of the block are such that it only appears at paths that match node/*

Thanks, all!

John Rand

related questions