Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Drupal View Dependencies?

Posted on 2011-05-11
12
Medium Priority
?
489 Views
Last Modified: 2012-05-11
Here's the setup:

Drupal 7 and Views 3.

Articles may or may not have images associated with them.  On my home page, there is a block that has a leading article with image and then a list of articles next to it (all within a particular category).  See screenshot below.  

Since not all articles have images, I split this up between two views.  The one on the left with the image has a filter that ensures I have an article with an image.  It picks the single latest one. The view on the right is just a straight pull of the latest 7 articles.

There is a chance, of course, that one of the latest 7 articles has an image, in which case it'd be duplicated on the right.  I want to, in the right list-only view, exclude the node listed on the left.  I've been googling all morning, and have come up empty.  I've dabbled with Views PHP but it doesn't seem to be working.

Any ideas?

Screenshot
0
Comment
Question by:michaelgiaimo
  • 5
  • 5
11 Comments
 
LVL 14

Expert Comment

by:dejaanbu
ID: 35740269
hi,

better you post this in  Drupal Zone. experts will come up with answers
0
 

Author Comment

by:michaelgiaimo
ID: 35740559
Sorry, didn't know there was a Drupal zone!  
0
 
LVL 16

Expert Comment

by:HagayMandel
ID: 35744074
I guess this leads to your "correct" home page: http://www.haileywiseman.com/node

In admin/settings/site-information, goto the home page URL, and correct it accordingly
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:HagayMandel
ID: 35744079
Sorry, ignore. I was answering another questions :-)
0
 

Author Comment

by:michaelgiaimo
ID: 35758493
No ideas?
0
 
LVL 16

Expert Comment

by:HagayMandel
ID: 35759232
As it seems, you're embedding 2 views in a page or using 2 blocks on a page..
I guess the easiest way to get this is create a difference between articles that have image(s), and one that don't.
You can add a field (has_image) to the article content type, and when an article has an image, this field will be checked. (you can even to it automatically by playing with preprocess in template.php.
Then, for the right block, you can filter the items to be last 7 items that don't have the has_image field checked.
0
 

Author Comment

by:michaelgiaimo
ID: 35768417
Thanks, but the problem with that is the ones on the right may have images and that's fine.

I'm filtering on whether an item has an image for the left block, using a 'not empty' file id.
0
 
LVL 16

Expert Comment

by:HagayMandel
ID: 35772289
In that case you have to work systematically:
1. Build the left block as you do now.
2. Start building the right block with exactly the same query you use for the left block. (the only difference is that you don't display the actual node).
3. Get the node id, and use it to filter the list on the right block.
0
 

Author Comment

by:michaelgiaimo
ID: 35776963
I don't quite understand what you mean.  Can you elaborate?
0
 
LVL 16

Accepted Solution

by:
HagayMandel earned 1500 total points
ID: 35783164
I'll try:

The first phase is to regularly generate the left block (with the image).
Then take this generated query, and use it for the initial stage of building the right block:
It will pull out the node id (nid) that is used on the left block.
Then  build the second query for the right block list, to be consisted of the last 7 articles, provided that the node id IS NOT the one pulled on the primal phase.
Example building the right block:
You run the query used for the left block, and it brings you the node id 1234.
Then you select the last 7 articles provided that their ids are different than 1234.
0
 

Author Closing Comment

by:michaelgiaimo
ID: 35890333
Sort of vague.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

575 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question