Hi All. This particular site I'm building features a layout with a photo in the upper right corner. The client wants to have the ability to specify the image on every single page. I know I know, kind of whacked, but it's what they want. So, first step was to use cck to add a new field to the "page" type. I tried imagefield but didn't like how you couldn't select an existing image. I managed to whip together a new cck field which uses IMCE to select the image (I'll up it to cvs after some more testing and some coworkers give me the thumbs up on its quality). Okay, so that takes care of any pages displaying a single node. How do I handle views? There are a few views and they obviously need to have the image customizable. It'd be nice if when creating a "view" to provide a page, it inherited the cck fields from the "page" type. Could I use form_alter to add the cck field to the views form? Or is there some way when the "view" is being built I can extract the image from the first node and pass it to page.tpl.php? Any help would be appreciated. Thanks in advance. -john
Funny you should mention it. I just got around to documenting the way we tackle this issue at Palantir today: http://drupal.org/node/180852 As for the Views, create a node type that has nothing but a title and Viewfield CCK type. Create a node of that type and specify the View to use. Tada, you have a node. Note: Doesn't work with dynamic arguments, sadly. :-( Cheers. On Thursday 04 October 2007, John Barreiros wrote:
Hi All.
This particular site I'm building features a layout with a photo in the upper right corner. The client wants to have the ability to specify the image on every single page. I know I know, kind of whacked, but it's what they want.
So, first step was to use cck to add a new field to the "page" type. I tried imagefield but didn't like how you couldn't select an existing image. I managed to whip together a new cck field which uses IMCE to select the image (I'll up it to cvs after some more testing and some coworkers give me the thumbs up on its quality).
Okay, so that takes care of any pages displaying a single node.
How do I handle views? There are a few views and they obviously need to have the image customizable. It'd be nice if when creating a "view" to provide a page, it inherited the cck fields from the "page" type.
Could I use form_alter to add the cck field to the views form?
Or is there some way when the "view" is being built I can extract the image from the first node and pass it to page.tpl.php?
Any help would be appreciated. Thanks in advance. -john
-- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson
Thanks for the response Larry. I'm trying to wrap my head around your solution, which for the most part makes sense. My only question is, does it work if you're viewing a "view" page? For example, I navigate to the "news" page which is just a view displaying the last 10 news nodes. Will the sidebar block display an image? thanks again. On 10/4/07, Larry Garfield <larry@garfieldtech.com> wrote:
Funny you should mention it. I just got around to documenting the way we tackle this issue at Palantir today:
As for the Views, create a node type that has nothing but a title and Viewfield CCK type. Create a node of that type and specify the View to use. Tada, you have a node. Note: Doesn't work with dynamic arguments, sadly. :-(
Cheers.
On Thursday 04 October 2007, John Barreiros wrote:
Hi All.
This particular site I'm building features a layout with a photo in the upper right corner. The client wants to have the ability to specify the image on every single page. I know I know, kind of whacked, but it's what they want.
So, first step was to use cck to add a new field to the "page" type. I tried imagefield but didn't like how you couldn't select an existing image. I managed to whip together a new cck field which uses IMCE to select the image (I'll up it to cvs after some more testing and some coworkers give me the thumbs up on its quality).
Okay, so that takes care of any pages displaying a single node.
How do I handle views? There are a few views and they obviously need to have the image customizable. It'd be nice if when creating a "view" to provide a page, it inherited the cck fields from the "page" type.
Could I use form_alter to add the cck field to the views form?
Or is there some way when the "view" is being built I can extract the image from the first node and pass it to page.tpl.php?
Any help would be appreciated. Thanks in advance. -john
-- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012
"If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson
You can get around that using CSS. Assuming you've placed the image in div#image set #news div#image img {display:none;} and then #news div#image {background:...}. I've got php code that will assign and ID and classes to the body tag based on which page you're on if you need help with that part of it. John Barreiros wrote:
Thanks for the response Larry. I'm trying to wrap my head around your solution, which for the most part makes sense. My only question is, does it work if you're viewing a "view" page? For example, I navigate to the "news" page which is just a view displaying the last 10 news nodes. Will the sidebar block display an image?
thanks again.
On 10/4/07, *Larry Garfield* <larry@garfieldtech.com <mailto:larry@garfieldtech.com>> wrote:
Funny you should mention it. I just got around to documenting the way we tackle this issue at Palantir today:
As for the Views, create a node type that has nothing but a title and Viewfield CCK type. Create a node of that type and specify the View to use. Tada, you have a node. Note: Doesn't work with dynamic arguments, sadly. :-(
Cheers.
On Thursday 04 October 2007, John Barreiros wrote: > Hi All. > > This particular site I'm building features a layout with a photo in the > upper right corner. The client wants to have the ability to specify the > image on every single page. I know I know, kind of whacked, but it's what > they want. > > So, first step was to use cck to add a new field to the "page" type. I > tried imagefield but didn't like how you couldn't select an existing image. > I managed to whip together a new cck field which uses IMCE to select the > image (I'll up it to cvs after some more testing and some coworkers give me > the thumbs up on its quality). > > Okay, so that takes care of any pages displaying a single node. > > How do I handle views? There are a few views and they obviously need to > have the image customizable. It'd be nice if when creating a "view" to > provide a page, it inherited the cck fields from the "page" type. > > Could I use form_alter to add the cck field to the views form? > > Or is there some way when the "view" is being built I can extract the image > from the first node and pass it to page.tpl.php? > > Any help would be appreciated. Thanks in advance. > -john
-- Larry Garfield AIM: LOLG42 larry@garfieldtech.com <mailto:larry@garfieldtech.com> ICQ: 6817012
"If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson
-- Sean Robertson Web Developer NGP Software, Inc. seanr@ngpsoftware.com (202) 686-9330 http://www.ngpsoftware.com
Thanks for the note Sean. I do create a custom body class which corresponds to the page, but I'm not sure that will help me. All is well when working with and viewing a single node. I can define the image and it displays nicely in the upper right corner. But, when I'm viewing a view, there doesn't seem to be a way to define the image to display in that upper right corner. -John On 10/4/07, Sean Robertson <seanr@ngpsoftware.com> wrote:
You can get around that using CSS. Assuming you've placed the image in div#image set #news div#image img {display:none;} and then #news div#image {background:...}. I've got php code that will assign and ID and classes to the body tag based on which page you're on if you need help with that part of it.
John Barreiros wrote:
Thanks for the response Larry. I'm trying to wrap my head around your solution, which for the most part makes sense. My only question is, does it work if you're viewing a "view" page? For example, I navigate to the "news" page which is just a view displaying the last 10 news nodes. Will the sidebar block display an image?
thanks again.
On 10/4/07, *Larry Garfield* <larry@garfieldtech.com <mailto:larry@garfieldtech.com>> wrote:
Funny you should mention it. I just got around to documenting the way we tackle this issue at Palantir today:
As for the Views, create a node type that has nothing but a title and Viewfield CCK type. Create a node of that type and specify the View to use. Tada, you have a node. Note: Doesn't work with dynamic arguments, sadly. :-(
Cheers.
On Thursday 04 October 2007, John Barreiros wrote: > Hi All. > > This particular site I'm building features a layout with a photo in the > upper right corner. The client wants to have the ability to specify the > image on every single page. I know I know, kind of whacked, but it's what > they want. > > So, first step was to use cck to add a new field to the "page" type. I > tried imagefield but didn't like how you couldn't select an existing image. > I managed to whip together a new cck field which uses IMCE to select the > image (I'll up it to cvs after some more testing and some coworkers give me > the thumbs up on its quality). > > Okay, so that takes care of any pages displaying a single node. > > How do I handle views? There are a few views and they obviously need to > have the image customizable. It'd be nice if when creating a "view" to > provide a page, it inherited the cck fields from the "page" type. > > Could I use form_alter to add the cck field to the views form? > > Or is there some way when the "view" is being built I can extract the image > from the first node and pass it to page.tpl.php? > > Any help would be appreciated. Thanks in advance. > -john
-- Larry Garfield AIM: LOLG42 larry@garfieldtech.com <mailto:larry@garfieldtech.com> ICQ: 6817012
"If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson
-- Sean Robertson Web Developer NGP Software, Inc. seanr@ngpsoftware.com (202) 686-9330 http://www.ngpsoftware.com
If you would like to customize the theming of a view, use the "theming wizard". It generates 3 pieces of code, namely code to insert into template.php(generates the necessary variables and a callback function which invokes the php template file), a php template file which generates the semantic html for the view, and a css file. Alternatively, you can invoke the view programatically in the page php template file, either with op "embed" to just insert the view somewhere on the page, or as "item" (see views_build_views comments in views.module), which will send you a hash of data which you can use as you like. The best views documentation can be found in the handbooks here: http://drupal.org/node/109604 It includes tutorials and is worth going over with a fine toothcomb. If you spend a day or so going over this documentation, you will be well-equipped to solve your problem using a variety of methods, and you will have a better foundation for future projects, rather than just seeking a quick fix. saludos, Victor Kane http://awebfactory.com.ar On 10/5/07, John Barreiros <johnbarreiros2@gmail.com> wrote:
Thanks for the note Sean.
I do create a custom body class which corresponds to the page, but I'm not sure that will help me. All is well when working with and viewing a single node. I can define the image and it displays nicely in the upper right corner. But, when I'm viewing a view, there doesn't seem to be a way to define the image to display in that upper right corner.
-John
On 10/4/07, Sean Robertson <seanr@ngpsoftware.com> wrote:
You can get around that using CSS. Assuming you've placed the image in div#image set #news div#image img {display:none;} and then #news div#image {background:...}. I've got php code that will assign and ID and classes to the body tag based on which page you're on if you need help with that part of it.
John Barreiros wrote:
Thanks for the response Larry. I'm trying to wrap my head around your solution, which for the most part makes sense. My only question is, does it work if you're viewing a "view" page? For example, I navigate to the "news" page which is just a view displaying the last 10 news nodes. Will the sidebar block display an image?
thanks again.
On 10/4/07, *Larry Garfield* <larry@garfieldtech.com <mailto: larry@garfieldtech.com>> wrote:
Funny you should mention it. I just got around to documenting the way we tackle this issue at Palantir today:
As for the Views, create a node type that has nothing but a title and Viewfield CCK type. Create a node of that type and specify the View to use. Tada, you have a node. Note: Doesn't work with dynamic arguments, sadly. :-(
Cheers.
On Thursday 04 October 2007, John Barreiros wrote: > Hi All. > > This particular site I'm building features a layout with a photo in the > upper right corner. The client wants to have the ability to specify the > image on every single page. I know I know, kind of whacked, but it's what > they want. > > So, first step was to use cck to add a new field to the "page" type. I > tried imagefield but didn't like how you couldn't select an existing image. > I managed to whip together a new cck field which uses IMCE to select the > image (I'll up it to cvs after some more testing and some coworkers give me > the thumbs up on its quality). > > Okay, so that takes care of any pages displaying a single node.
> > How do I handle views? There are a few views and they obviously need to > have the image customizable. It'd be nice if when creating a "view" to > provide a page, it inherited the cck fields from the "page"
type.
> > Could I use form_alter to add the cck field to the views form? > > Or is there some way when the "view" is being built I can
extract
the image > from the first node and pass it to page.tpl.php? > > Any help would be appreciated. Thanks in advance. > -john
-- Larry Garfield AIM: LOLG42 larry@garfieldtech.com <mailto:larry@garfieldtech.com> ICQ:
6817012
"If nature has made any one thing less susceptible than all others
of
exclusive property, it is the action of the thinking power called
an
idea, which an individual may exclusively possess as long as he keeps it
to
himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of
it." --
Thomas Jefferson
-- Sean Robertson Web Developer NGP Software, Inc. seanr@ngpsoftware.com (202) 686-9330 http://www.ngpsoftware.com
Victor, If you would like to customize the theming of a view, use the "theming
wizard".
I'm not trying to theme a view. That's easy enough to do. My problem is that there is a graphical element in page.tpl.php which changes depending on the webpage (which is defined via a cck field on the node). It generates 3 pieces of code, namely code to insert into template.php Thats kind of the problem. The view is generated and inserted into the $content variable. So at the hook=page level, I can't access any of the properties of the nodes included in the view. -john On 10/5/07, Victor Kane <victorkane@gmail.com> wrote:
If you would like to customize the theming of a view, use the "theming wizard".
It generates 3 pieces of code, namely code to insert into template.php(generates the necessary variables and a callback function which invokes the php template file), a php template file which generates the semantic html for the view, and a css file.
Alternatively, you can invoke the view programatically in the page php template file, either with op "embed" to just insert the view somewhere on the page, or as "item" (see views_build_views comments in views.module), which will send you a hash of data which you can use as you like.
The best views documentation can be found in the handbooks here:
It includes tutorials and is worth going over with a fine toothcomb.
If you spend a day or so going over this documentation, you will be well-equipped to solve your problem using a variety of methods, and you will have a better foundation for future projects, rather than just seeking a quick fix.
saludos,
Victor Kane http://awebfactory.com.ar
On 10/5/07, John Barreiros < johnbarreiros2@gmail.com> wrote:
Thanks for the note Sean.
I do create a custom body class which corresponds to the page, but I'm not sure that will help me. All is well when working with and viewing a single node. I can define the image and it displays nicely in the upper right corner. But, when I'm viewing a view, there doesn't seem to be a way to define the image to display in that upper right corner.
-John
On 10/4/07, Sean Robertson < seanr@ngpsoftware.com> wrote:
You can get around that using CSS. Assuming you've placed the image in div#image set #news div#image img {display:none;} and then #news div#image {background:...}. I've got php code that will assign and ID
and classes to the body tag based on which page you're on if you need help with that part of it.
John Barreiros wrote:
Thanks for the response Larry. I'm trying to wrap my head around your solution, which for the most part makes sense. My only question is, does it work if you're viewing a "view" page? For example, I navigate to the "news" page which is just a view displaying the last 10 news nodes. Will the sidebar block display an image?
thanks again.
On 10/4/07, *Larry Garfield* < larry@garfieldtech.com <mailto: larry@garfieldtech.com>> wrote:
Funny you should mention it. I just got around to documenting the way we tackle this issue at Palantir today:
As for the Views, create a node type that has nothing but a title and Viewfield CCK type. Create a node of that type and specify the View to use. Tada, you have a node. Note: Doesn't work with dynamic arguments, sadly. :-(
Cheers.
On Thursday 04 October 2007, John Barreiros wrote: > Hi All. > > This particular site I'm building features a layout with a photo in the > upper right corner. The client wants to have the ability to specify the > image on every single page. I know I know, kind of whacked, but it's what > they want. > > So, first step was to use cck to add a new field to the "page" type. I > tried imagefield but didn't like how you couldn't select an existing image. > I managed to whip together a new cck field which uses IMCE to select the > image (I'll up it to cvs after some more testing and some coworkers give me > the thumbs up on its quality). > > Okay, so that takes care of any pages displaying a single node. > > How do I handle views? There are a few views and they obviously need to > have the image customizable. It'd be nice if when creating a "view" to > provide a page, it inherited the cck fields from the "page" type. > > Could I use form_alter to add the cck field to the views form? > > Or is there some way when the "view" is being built I can extract the image > from the first node and pass it to page.tpl.php? > > Any help would be appreciated. Thanks in advance. > -john
-- Larry Garfield AIM: LOLG42 larry@garfieldtech.com <mailto: larry@garfieldtech.com> ICQ:
6817012
"If nature has made any one thing less susceptible than all
others of
exclusive property, it is the action of the thinking power
called an
idea, which an individual may exclusively possess as long as he keeps
it to
himself; but the moment it is divulged, it forces itself into
the
possession of every one, and the receiver cannot dispossess himself of
it." --
Thomas Jefferson
-- Sean Robertson Web Developer NGP Software, Inc. seanr@ngpsoftware.com (202) 686-9330 http://www.ngpsoftware.com
But, the theming wizard gives you a much more granular list of variables to work with, one for each field. So you can "intercept" the content. Instead of printing $content or the embedded view itself, you will print $views-xxxxx-xxxxx-data-content It breaks the $content variable down into its parts, for each field, a variable for the label and a variable for the data. Another thing the theming wizard does is give you a list of view variables you can invoke. On 10/5/07, John Barreiros <johnbarreiros2@gmail.com> wrote:
Victor,
If you would like to customize the theming of a view, use the "theming
wizard".
I'm not trying to theme a view. That's easy enough to do.
Well, but "theming" includes modifying the actual semantic data also.
No, it only works on a node page, because only on a node do you get the ability to add CCK fields. However, you can create a "view node" as described below, add the same Sidebar image field to it (remember CCK fields can be added to multiple node types), and then create a node of that type that references your "latest news" view. You lose dynamic argument support that way, but pretty much everything else should work normally. I suspect Panels 2 has some even slicker solution, but I've not worked with it yet. :-) On Thursday 04 October 2007, John Barreiros wrote:
Thanks for the response Larry. I'm trying to wrap my head around your solution, which for the most part makes sense. My only question is, does it work if you're viewing a "view" page? For example, I navigate to the "news" page which is just a view displaying the last 10 news nodes. Will the sidebar block display an image?
thanks again.
On 10/4/07, Larry Garfield <larry@garfieldtech.com> wrote:
Funny you should mention it. I just got around to documenting the way we tackle this issue at Palantir today:
As for the Views, create a node type that has nothing but a title and Viewfield CCK type. Create a node of that type and specify the View to use. Tada, you have a node. Note: Doesn't work with dynamic arguments, sadly.
:-(
Cheers.
On Thursday 04 October 2007, John Barreiros wrote:
Hi All.
This particular site I'm building features a layout with a photo in the upper right corner. The client wants to have the ability to specify the image on every single page. I know I know, kind of whacked, but it's
what
they want.
So, first step was to use cck to add a new field to the "page" type. I tried imagefield but didn't like how you couldn't select an existing
image.
I managed to whip together a new cck field which uses IMCE to select the image (I'll up it to cvs after some more testing and some coworkers give
me
the thumbs up on its quality).
Okay, so that takes care of any pages displaying a single node.
How do I handle views? There are a few views and they obviously need to have the image customizable. It'd be nice if when creating a "view" to provide a page, it inherited the cck fields from the "page" type.
Could I use form_alter to add the cck field to the views form?
Or is there some way when the "view" is being built I can extract the
image
from the first node and pass it to page.tpl.php?
Any help would be appreciated. Thanks in advance. -john
-- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012
"If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson
-- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson
Larry, So I became so wrapped up in your article that I missed your second paragraph. The viewfield CCK type worked awesome. Solved my issue perfectly. Thanks again. On 10/4/07, Larry Garfield <larry@garfieldtech.com> wrote:
Funny you should mention it. I just got around to documenting the way we tackle this issue at Palantir today:
As for the Views, create a node type that has nothing but a title and Viewfield CCK type. Create a node of that type and specify the View to use. Tada, you have a node. Note: Doesn't work with dynamic arguments, sadly. :-(
Cheers.
On Thursday 04 October 2007, John Barreiros wrote:
Hi All.
This particular site I'm building features a layout with a photo in the upper right corner. The client wants to have the ability to specify the image on every single page. I know I know, kind of whacked, but it's what they want.
So, first step was to use cck to add a new field to the "page" type. I tried imagefield but didn't like how you couldn't select an existing image. I managed to whip together a new cck field which uses IMCE to select the image (I'll up it to cvs after some more testing and some coworkers give me the thumbs up on its quality).
Okay, so that takes care of any pages displaying a single node.
How do I handle views? There are a few views and they obviously need to have the image customizable. It'd be nice if when creating a "view" to provide a page, it inherited the cck fields from the "page" type.
Could I use form_alter to add the cck field to the views form?
Or is there some way when the "view" is being built I can extract the image from the first node and pass it to page.tpl.php?
Any help would be appreciated. Thanks in advance. -john
-- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012
"If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson
participants (4)
-
John Barreiros -
Larry Garfield -
Sean Robertson -
Victor Kane