<div dir="ltr">Hello all,<br><br>I&#39;ve searched the net all over for the particular case I have but couldn&#39;t find an answer. I have a view with an argument, based on this argument, I would like to either pass it through, or join to two more tables and add a where clause to my query that is pretty unrelated to the argument type. For example, let&#39;s say the argument is a tid and I want to add a where clause to the files table if this tid was equal to 5, otherwise, I want it to function normally. For this I looked into the hook_views_query_alter hook<br>
<br>The problems I faced in order:<br><br>1. The cck file field that contains the fid was not in the fields list, so the table wasn&#39;t even in the joins, I resolved this by adding the cck file field to the fields list although I have no use for it. But this at least added the table to the view object in this hook (I didn&#39;t really want to add a field in vain just to get its table to show up in the view-&gt;query object).<br>
2. After doing that, I needed to do a join from the table in #1 to the files table, again, the files table was not inside the view-&gt;query and this is where I got stuck.<br>3. Assuming #2 works, I will finally add a where clause to the files table.<br>
4. Let&#39;s say I did all this successfully, I would need to remove the tid that was passed in the argument so that it would not be rendered inside the query (i.e. where tid = 5).<br><br>Is there any guidelines on how to fully handle the view, view-&gt;query objects? All I could find were hacks to add sort by, add simple wheres to tables that were already in the views object, and to create aliases for tables that are, again, already in the view object. None of them with the complexity I need. <br>
<br>I&#39;ve hesitated on weather this should be in the views issue queue or here, but I think many agree views is no longer an optional module. If I do get this resolved I&#39;ll be more than happy to post it on our site or to create a views issue with the details.<br>
<br clear="all"><br>-- <br>Ashraf Amayreh<br>CEO | O-Minds<br>Cell. 962 78 8099997<br>Tel. 962 6 5655150<br>Fax. 962 6 5675150<br>Skype: aamayreh<br><br><a href="http://www.o-minds.com">www.o-minds.com</a><br>web development | web design<br>
user experience | branding design<br><br>Connect with us on Twitter<br><a href="http://twitter.com/ominds">http://twitter.com/ominds</a><br><br>Connect with us on LinkedIn<br><a href="http://www.linkedin.com/in/aamayreh">http://www.linkedin.com/in/aamayreh</a><br>

</div>