kellybelly
asked on
Drupal 5.X - block visible based on field and URL
I have created a custom content type where I will enter information that needs to appear in a block in the sidebar on specific pages. It will contain information about specific brands that our company carries, and needs to show up when the title or URL of the page contains that brand's name.
so what I did was make a field in the custom content called "Brand" and I want to make the content show up in a block when the title or URL contain that string.
Can anyone point me in the right direction past that. To demonstrate how lost I am - right now that block shows all of the content of the entire site.
so what I did was make a field in the custom content called "Brand" and I want to make the content show up in a block when the title or URL contain that string.
Can anyone point me in the right direction past that. To demonstrate how lost I am - right now that block shows all of the content of the entire site.
Some weird characters have come out, they're all single quotes
ASKER
is that code for the arguments in the view, or the block visibility?
In the block visibility. You could modify and put that in the arguments in the view. Depends what you want to do. If you want it to appear for just one brand then it's easier to put it in the visibility however you may still have the overhead of the view generating the block on every page even if it doesn't display, not sure about that one. If you want it to appear different for different brands then yes you would need to add it to the argument which is actually an example I took some code from but it's for Drupal 6, not sure about 5: http://www.ridgesolutions.ie/index.php/2009/01/19/passing-an-argument-to-a-block-view-in-drupal-6/
My comment is wrong by the way!
My comment is wrong by the way!
ASKER
the content type has a field in it called 'field_brand'
if I put the code above in and replaced [YOUR BRAND NAME] with $field_brand should that make it show the quick facts box only when the brand name is present in the URL?
if I put the code above in and replaced [YOUR BRAND NAME] with $field_brand should that make it show the quick facts box only when the brand name is present in the URL?
I've got an idea but I'm not sure if you can do it in views 1. What you could do is create a content type that contains your quick facts. You could create a taxonomy of brand names that links your node with your quick facts. Then you can create a relationship between your node and your quick facts based on brand. An alternative would be to store your quick facts in your node buy creating pre defined values in your content type which you could then select. You could create a template for this content type which would allow you to position your quick facts, or you might find you can do all you want with CSS.
ASKER
these all sound like good options - I will have to spend a little time with taxonomy. What you are suggesting with that was something that had occurred to me also.
It seems like this is probably something that people do all the time - having certain type of content that shows up in a block and the actual node changes based on the page selected. How would it be handled normally? (I am trying to make sure that I am not making this more complicated than it has to be.)
It seems like this is probably something that people do all the time - having certain type of content that shows up in a block and the actual node changes based on the page selected. How would it be handled normally? (I am trying to make sure that I am not making this more complicated than it has to be.)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You may need to do some fiddling with the elements of the array and the brand name to make sure they match. e.g. if your path says /content/my-brand-name, and your Brand name is My Brand Name, then you would need to convert the brand name to lowercase and convert spaces to hyphens
Open in new window