Skip to content

Instantly share code, notes, and snippets.

@CreativePoweredGeek
Last active April 21, 2020 13:13
Show Gist options
  • Save CreativePoweredGeek/f1d127ad2a4621971788d92c6bc7ba60 to your computer and use it in GitHub Desktop.
Save CreativePoweredGeek/f1d127ad2a4621971788d92c6bc7ba60 to your computer and use it in GitHub Desktop.
ExpressionEngine Query Snippets
<!-- This grabs All titles based on uer and channel ID -->
{exp:query sql="SELECT DISTINCT title AS item FROM exp_channels WHERE channel_id = 'your_channel_id' AND author_id = '{logged_in_member_id}'"}
{embed="embeds/product_row" keltec_number="{item:url_slug}"}
{/exp:query}
<!-- This grabs the total entries of a Channel -->
<!-- this can be achieved easier with the {exp:stats} tag but it's good for practive and reference. -->
<!-- Just grab the Channel ID of the desired channel from the Channels Page in the Control Panel -->
{exp:query sql="SELECT total_entries FROM exp_channel_titles WHERE channel_id = 'your_channel_id'"}
{total_entries}
{/exp:query}
<!-- Example of a JOIN within ee:query - This is on the Members Tables - Ver 5 -->
<!-- Fields should be changed out to match the needed query -->
{exp:query sql="
SELECT * FROM exp_member_data_field_3
INNER JOIN (exp_members INNER JOIN exp_member_data_field_8 on exp_members.member_id = exp_member_data_field_8.member_id)
ON exp_members.member_id = exp_member_data_field_3.member_id
WHERE exp_members.last_visit !=0 GROUP BY exp_members.member_id ORDER BY exp_members.member_id ASC
}
{/exp:query}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment