Retrieving SQL query behind channel entries tag - expressionengine

EE 2.5.5
I'd like to find the exact SQL query that is run by a channel entries tag, I've tried displaying the database queries by I can't see any related to running a channel entries tag.
I've simplified the template and now just have the tag in it:
{exp:channel:entries channel="mychannel"
disable="member_data|comments|trackbacks|categories" dynamic="no" require_entry="yes"}
{title}
{/exp:channel:entries}

I hope I'm understanding what you need.
Try using {total_results} as opposed to {total_entries} or are you looking for something like SELECT COUNT(entry_id) FROM exp_channel_titles WHERE status="open"
Edit:
If your output profiler is enabled in the backend you should be able to see something like the image below. In the orange text you'll see build query function I'm speaking of.

Related

How to access custom fields in the category of a relationship field in expressionengine?

I have a custom field on my category group, called colour. I'm using a relationship field to pull the categories of the related entry into my page, but can't figure out how to get the 'colour' of the category of the related entry.
Getting the name of the category works fine by using
{exp:channel:entries channel="parent"}
{related_entry}
{related_entry:categories}
{category_name}
{/related-entry:categories}
{/related_entry}
{/exp:channel:entries}
so I would've assumed that accessing the custom field would be possible in a similar way, such as
{exp:channel:entries channel="parent"}
{related_entry}
{related_entry:categories}
{colour}
{/related-entry:categories}
{/related_entry}
{/exp:channel:entries}
but I'm having no luck. Is this possible?
Isn't it supposed to be like this? I think in your sample code, the category_name is parsed from the channel entries and not from the related_entry.
{related_entry:categories:category_name} and {related_entry:categories:colour}

Expression Engine - Is it possible for exp:channel:entries tag to have complex filters?

Coming from Codeigniter and new to Expression Engine, I am at a loss on how to do complex filters on the exp:channel:entries tag.
I am interested in this filters
status
start_on
stop_before
How do you do you implement filters for a complex condition like this?
(status=X|Y|Z AND start_on=A AND stop_before=B) OR (status=X AND start_on=C AND stop_before=D)
Is this even possible?
You can only use the search= parameter to search on “Text Input”, “Textarea”, and “Drop-down Lists” fields unfortunately. So you'd need to use the query module for this.
If you're just querying on those parameters you should be able to get the entry id's you need from the exp_channel_titles table, then use something like the Stash plugin to feed the entry_id's of the results into a regular channel entries tag. Yes it's nominally one more query that way but as EE abstracts the db schema fairly heavily the alternative is to get lost in a mess of JOINs.
So something like (pseudocode, won't work as is):
Get the entries, statuses are just a string in exp_channel_titles, entry_date is the date column you want - which is stored as a unix timestamp, so you'll need to select it with something like DATE( FROM_UNIXTIME(entry_date)) depending on the format of your filter data.
{exp:stash:set name="filtered_ids"}{exp:query sql="SELECT entry_id
FROM exp_channel_titles
WHERE status LIKE ...<your filter here>"
backspace="1"
}{entry_id}|{/exp:query}{/exp:stash:set}
Later in template:
{exp:channel:entries
entry_id="{exp:stash:get name="filtered_ids"}"
}
{!--loop --}
{/exp:channel:entries}
Yes it's a mess compared to what you're probably used to in pure CI, but the trade off is all the stuff you get for free from EE (CP, templating, member management etc).
Stash is awesome by the way - can be used to massively mitigate most EE performance issues/get around parse order issues
You can get a lot of this functionality using the search= parameter in your {exp:channel:entries...} loop.
It's not immediately clear to me how you'll get the complexity you seek, so you might end up resorting to the query module though.
If you're working with dates you might find the DT plugin useful.

pagination in playframework

I want to implement pagination in Play FrameWork , Is there any tutorial or example for this
I have explore there website and went through the tutorial but not able to implement pagination
Thanks
I have implemented many pages in play! using the Play pagination module. It's working fine with no issues. I'll give you an idea of what I did, below.
First I declare the ValuePaginator that points to a result set (in my case a MYSQL query)
ValuePaginator vpaginator=query.resultList();
Then render the Paginator instance to use it in the view
render(vpaginator);
In the view, I used the following syntax
#{paginate.list items:paginator, as:'r'}
<table>
<tr>
<td>${r[0]}</td>
<td>${r[1]}</td>
<td>${r[2]}</td>
</tr>
</table>
#{/paginate.list}
Suppose my SQL query looks like this
Select name,id,address from table
then in that case r[0] will take the value of names, r[1] will take the value of id's and r[2] will take the value of addresses and render this data in 3 different columns in a table.
Hope this helps.
First solution is to use the paginate-module. Furthermore there was a discussion of different implementations to solve it at google-group one result of it can find at the snippet-page.
I hope that one of the solution fits to you.

Can you use dynamic finders or grouping tables via scaffold in Grails?

I'm working on a very, very quick and dirty application using almost entirely scaffold to do it. This is only for internal use, and it's just to replace a spreadsheet, so while I know that I shouldn't rely on scaffolds for real production use, I still intend to use them where I can for efficiency (...just wanted to make sure we aren't taken off track by the inevitable question!).
What I am curious about is since scaffolds can do quick and dirty CRUD, and you can do dynamic finders for searches, is there a way to dynamically show the "list" action of the scaffold with a constraint (i.e. show all items in the list that were created by this "user")? That would be fine for me...
Alternatively, is there anything available in Grails to allow "grouped" tables. Essentially the "list" action from the scaffold, but grouped by a particular attribute (again, think of grouping all the items by the user that created them).
Any help would be appreciated - I've scoured Google and some books with no luck, but wanted to check with the StackOverflow community before I dismiss the notion and write it by hand. Thanks!
We did the same in our Grails application and it's relatively easy:
Create a new form in the list.gsp referring to the list action <g:form action="list" method="post">
Inside that form, declare a table with the fields you want to search on:
<div class="buttons">
<span class="button"><g:submitButton name="list" class="search" value=" ${message(code: 'default.button.search.label', default: 'Search')}"/></span>
</div>
In the list action, build up the query (using findAll, findWhere, .. whatever takes your fancy) and return that to the page:
[wardInstanceList : Ward.findAll(whereClause, [max: params.max, offset: params.offset]) , wardInstanceTotal : (int) Ward.executeQuery("select count(*) " + whereClause).get(0)]
The whereClause looks something like: "from Ward where ward = 'something' and room = 'something else'"

Content Query Web Part - How do you OrderBy when you QueryOverride?

How do you order items when you override the QueryOverride property of the Content Query Web Part?
I have been given responsibility for a Web Part which extends the Content Query Web Part. The QueryOverride property of this Web Part is programmatically changed. Currently, the Web Part does not function as designed, as it does not order the items according to the appropriate field.
If I add an <OrderBy> node to the QueryOverride property I get an error message along the lines of 'something wrong with the query this web part is...' and the Content Query Web Part doesn't seem to have an OrderBy property which I could use instead.
The "QueryOverride property" part of this msdn article seems to suggest I should be able to add an <OrderBy> node to the QueryOverride but a number of web sites I've been reading suggest that this is not true.
So, how do you order items when you override the QueryOverride property of the Content Query Web Part?
Does your QueryOverride statement contain any Whitespace/linebreaks by any chance? I think I recall a while back having a situation where the QueryOverride needed to be all contained on one line, with no spaces between xml tags.
Weird I know, but try it out.
Also, for reference see the first community comment on the MSDN page http://msdn.microsoft.com/en-us/library/aa981241.aspx
THanks for this. Just to clarify, there should be no white spaces before or after the tags as well.
This did not work:
<![CDATA[
<OrderBy><FieldRef Name="EndDate" Ascending="False"/></OrderBy>
<Where>
But this did:
<![CDATA[<OrderBy><FieldRef Name="EndDate" Ascending="False"/></OrderBy><Where>
Wierd but thanks again for posting this answer, it saved me a lot of time.

Resources