0

Ok, I'll try to describe the scenario I am facing since I can't narrow it down to sub-questions to see what feedback I can get.

Say I am constructing an e-commerce site that sells cakes (I love that example as it seems).

I have already created a view that shows all my cakes sorted alphabetically as thumbnails and also one view that shows all my cakes at a themed alphabetical 'catalogue' style (as this question shows) and both views link to eachother.

All nice and nifty.

Now what's come up is that the cakes are tagged with taxonomy terms that mark their... ehh.. flavor, their size, and say their... use (party - wedding - just a normal cake). I know the example is stupid but you get the idea.

The tricky part comes when I need a global (global as in available in all pages throughout the site) dropdown list menu that lists those taxonomy terms and upon selection takes the user to the first view (the thumbnail one) which is filtered only with the cakes that match the selected taxonomy.

I hear you mumbling that that's easy and that contextual filters is all I need. And I agree, and I've done that.

The tricky part comes now: If the user was lead to the view by this route and he clicks to go to the 'catalogue' view, the cakes that match, should be higlighted and if the user is in the 'catalogue' view and selects another taxonomy term from the menu he should remain in the current view and the appropriate cakes should be highlighted. Also if he should go back to the 'thumbnail' view, it should be also be filtered accordingly.

So, recap:

1) clicking a taxonomy term leads to a filtered 'thumbnail' view.
2) clicking the 'catalogue' view link while on the filtered 'thumbnail' view leads to a highlighted 'catalogue' view and vice versa.
3) clicking on taxonomy while on either 'thumbnail' or 'catalogue' view should perform the aforementioned mentioned actions.
4) if the user navigates away from either of the pages the whole process resets until a taxonomy is selected again.

P.S. on the 'catalogue' view the cakes' divs have their taxonomy tags as classes to make highlighting easier.

Thanks for your time in advance.

EDIT: I managed using arg(x) to make the links from one view to another dynamic, i.e:

if the user is in www.cakes.com/Cakes/AllCakes/[tid] and clicks the link to the 'catalogue' view, the link instead leads to www.cakes.com/Cakes/AllCakesList/[tid] which is filtered, which leads to the following question too:

5) is there a way to use contextual filters NOT for filtering but for other functions like adding a CSS class for instance?

EDIT #2: Marking with strikethrough the tasks already completed.

EDIT #3: First EDIT marked since filtering is (obviously) not the way to go. But since I have the [tid] on the URL and thus on arg(x) I could somehow use it to highlight the appropriate divs.

EDIT #4: Managed via inline javascript and using the arg(x) argument to highlight the cakes in the 'catalogue' view!

1 Answer 1

1

It's funny how some times after you ask someone or a community for some solution you actually see the problem more clearly.

I was able to complete all of the mentioned tasks and I will summarize here just in case someone bizarrely stumbles upon a similar scenario in the future - although I really doubt it.

So, the views linking to each other dynamically was accomplished using the [tid] argument from the URL and passing it accordingly:

<a href="/Cakes/AllCakes/<?php echo arg(2);?>"></a>
<a href="/Cakes/AllCakesList/<?php echo arg(2);?>"></a>

The jump menu itself is set to Link to the thumbnail view by default unless the url is that of the 'catalogue' view. If so, via theming:

<?php if (arg(1) == 'AllCakesList'){
  $output=  str_replace("/AllCakes/" , "/AllCakesList/",$output);
}?>
<?php print $output; ?>

It leads to the 'catalogue' view.

And if the user is on none of those pages, the jump menu will lead him to the thumbnail view thus also fulfilling the 4th task in my question. That's all folks, sorry for the monstrous post!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.