Hi friends, i cant find the correct settings for this, i have a content type "images" with date field showing the day the photo was taken, i need a views block that shows photos with the same date of the current node
how to get this?
thanks

CommentFileSizeAuthor
example.jpg278.95 KBAcertijo

Comments

Acertijo created an issue. See original summary.

shewaleanjali’s picture

You can achieve it through query alter hook for views i.e. hook_query_alter .

saurabh.dhariwal’s picture

You can use following steps:

1. Create content view which display image field.
2. Then add date field to filter criteria and set operation 'contains' and set any date to value field and save view.

And then using hook_views_query_alter alter value of date as following:

function YOURMODULE_views_query_alter(&$view, &$query) {
        if($view->name == 'VIEW_NAME' && $view->current_display == 'DISPLAY_ID' ) {
                $nid = arg(1);// get node id from url
                $node = node_load($nid); // load node
                $current_node_date = $node->field_date[LANGUGE_NONE][0]['value']; // get current node date
                $query->where['1']['conditions']['2']['value'] = $current_node_date;
        }
}

Hope it helps you.

Thanks!

renatog’s picture

Status: Active » Reviewed & tested by the community

Hi guys.

I checked and #3 it's ok.

@Acertijo, you can follow this steps for it.

renatog’s picture

Status: Reviewed & tested by the community » Fixed

Thank you very much @shewaleanjali and @saurabh.dhariwal for your contributions.

Best,

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.