Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I am working on getting my calendar views setup to allow 'print-friendly' output. To do this I am embedding a view in a node, like this:
<?php
print views_embed_view('calendar', 'calendar_1');
?>
This works fine, but I'd like to be able to specify the month for the view which means I need to pass args to the view.
My url would look like this (using pathauto):
http://www.my.site/content/print-calendar/2010-01
But, I can't figure out what I need to add to the php embedding to get my argument to work with the view. I've tried variations of this:
<?php
print views_embed_view('calendar', 'calendar_1', $args[2]);
?>
with no luck (the system throws a 404 error).
Any help would be greatly appreciated.
Comments
Comment #1
kongoji CreditAttribution: kongoji commentedI had your same problem. The workaround I found was to don't pass arguments in views_embed_view, but to let a custom php script in views' date argument do the job picking the date from url.
Example:
Then in the view's date argument (using your url http://www.my.site/content/print-calendar/2010-01):
Change the code to better fit your needs. Hope it helps!
Comment #2
Artusamak6.x is entirely unmaintained.