Hi,

I was wondering if anyone could tell me if their is a solution for the following:

I have a view embedded in a page with the path "events/john". This view is embedded through the use of contemplate and views_embed function into an event content type. This view contains all events from John. In this view i have also enabled rss, but I can't get the rss path the way I want it. The rss path settings in the view forces to use the base path with % as arguments, but i want it to be relative, or I should say, to read the current url and put the "/rss" behind it.

Is there any way to read/get the current url of the page the view is embedded in, and use that as a base path so i can get the rss path to be "events/john/rss" ??

Thanks!

Max

Comments

merlinofchaos’s picture

Status: Active » Fixed

AS part of your embedding, you can:

$view->override_path = $_GET['q']

Though this gets a little tricky with arguments since it'll try to append those to the path.

If you're using views_embed_view() you'll need to do what the function does, since you just give views_embed_view() a view name, not a full view object. But the funciton is quite short; just take what it does, insert the line of code above after the view's been loaded and it should work.

tezalsec’s picture

Thanks so much for your reply. I have been trying to do this, but i can't seem to get it working.

When there is no view object used in the views_embed_view function, how can the url parameter then be loaded into it?

As an alternative I have also been trying to use the views_get_view function to load it into the view object, through the use of

$view1 = views_get_view('events_personal','default', $UID);
$view1->override_path = $_GET['q'];
$viewsoutput = $view1->preview();
print $viewsoutput;

but with this the page turns WSOD. The phpcode area within contemplate doesnt seem to allow the preview() function. Am I than forced to put the code elsewhere, like in template.php or a dedicated module?

Any suggestions on how to handle this?

tezalsec’s picture

Status: Fixed » Active
dawehner’s picture

$view1 = views_get_view('events_personal','default');
$args = array($uid);
$view1->override_path = $_GET['q'];
$viewsoutput = $view1->preview($args);
print $viewsoutput;

Does this work for you?

tezalsec’s picture

Unfortunately no, same result. I should correct myself in my earlier post, it doesn't go WSOD, it shows only a white screen with one example record as seen in the available body variables... nothing relevant or associated with the right User ID.

Any other way to accomplish this?

Thanks!

iamjon’s picture

Project: Views (for Drupal 7) » Content Templates (Contemplate)
Version: 6.x-2.11 » 6.x-1.2
Component: feed displays » Code

Hi Maxim75,
Did you ever find a solution for this issue?
I spoke to dereine about this on irc and it seems to be a contemplate issue. moving issue there.

tezalsec’s picture

Hi iamjon,

unfortunately, no, i haven't. For now I have accepted the user-nid instead of the user name, hoping for a future solution. I also felt it had to be contemplate not accepting the use of necessary functions.

Another problem i have run into many times in the phpcode area within contemplate, is using the "%d" as a variable within queries to avoid sql injection, it won't save, but that is another issue.

Thanks for the feedback, hopefully it gets picked up by the contemplate maintainers.

Max