{IF_CATALOGUE_ENTRY_EXISTS}

Post

Posted
Rating:
#6364 (In Topic #1607)
Avatar
Standard member
Terry is in the usergroup ‘Fan in action’
I am trying to show the Member a list of things to do (that they have not yet done).

{+START,IF_EMPTY,{$PHOTO}}
     … You can add a photo …
{+END}

{+START,IF_EMPTY,{$AVATAR}}
     … You can add an avatar …
{+END}

What I'd like to do next is find out if they posted in a Specific CATALOGUE. To do that, there would be an ENTRY into that Specific CATALOGUE in ce_submitter (I think) that matches the Member's ID. If such an ENTRY exists, then they posted in that CATALOGUE. If it didn't, then I can print something that says "You can Post in CATALOGUE X"

I tried these Tempcode commands:

{$CATALOGUE_ENTRY_BACKREFS,1}
{$CATALOGUE_ENTRY_FIELD_VALUE,1,0}
{$CATALOGUE_ENTRY_FIELD_VALUE_PLAIN,1,0}
{$CATALOGUE_ENTRY_FOR,download,3}
{$CATALOGUE_ENTRY_ALL_FIELD_VALUES,1}

They are probably returning arrays or something, because they don't print anything out on return to the Tempcode page I put them in.

I can do this in PHP, but I'd have to turn on the ability to use PHP in Tempcode pages, and if I do that, it kind of diminishes the value of Tempcode. Can I get a better understanding of what these Tempcode commands return, so that I can see if one of them will tell me if the current Member has posted something to a Specific CATALOGUE.

Ultimately, if this Tempcode doesn't exist, it would be pretty handy to have something like this:

{+START,IF_EMPTY,{$CATALOGUE_ENTRY_MATCHES,<catalogue name>,<col>,<value>}}
     <p>You still haven't posted in our blah database</p>
{+END}


 
Online now: No Back to the top

Post

Posted
Rating:
#6366
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
All but one of the example Tempcode symbol usages you posted assume there is a catalogue entry #1.
{$CATALOGUE_ENTRY_BACKREFS,1} additionally assumes that there is another catalogue entry with a field referencing entry #1.
{$CATALOGUE_ENTRY_FOR,download,3} is assuming there is a download #3 and that you have defined at least one custom downloads field, and download #3 was added/edited subsequent to that field being created.

None of the symbols are related specifically to querying for a particular member. Mostly it's catalogue entry #1 regardless of whether the current user was the original submitter of that entry.

To amuse myself, I did work out a way you can do it:

Code

{$IS_NON_EMPTY,{$BLOCK,block=main_multi_content,render_if_empty=0,param=catalogue_entry,max=1,filter=ce_submitter={$MEMBER}}}

However, that is awful and I definitely do not recommend it ;). It's rendering out the 1 content item that comes back when you query catalogue entries submitter for the current user (using Filtercode) and seeing if that response is empty or not.

I'll see if I can suggest something better.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Adam)
#6367
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
The correct approach to requiring extra logic components in Tempcode is to write a symbol, which I have done for you.

Attachment

content_count.tar


This will tell you how many catalogue entries the current user has:
{$CONTENT_COUNT,catalogue_entry,ce_submitter={$MEMBER}}

So if it is non-zero then it means they have entries.

You can query any Composr content type (find content type codenames by looking to see what files are in sources/hooks/content_meta_aware) with any Filtercode string you want.

ce_submitter is literally the field name in the catalogue_entries table.

I like my symbol, I'll add it to tracker for consideration in core for future versions.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#6370
Avatar
Standard member
Terry is in the usergroup ‘Fan in action’
I think this is very slick! With this code, is there a way to AND the WHERE argument…like this…

{$CONTENT_COUNT,catalogue_entry,ce_submitter={$MEMBER} AND c_name=links}
{$CONTENT_COUNT,catalogue_entry,ce_submitter={$MEMBER} AND c_name=faqs}
{$CONTENT_COUNT,catalogue_entry,ce_submitter={$MEMBER} AND c_name=recipes}

So that it more selectively counts the number of catalogue entries in different catalogues?



 
 
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5
#6371
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
{$CONTENT_COUNT,catalogue_entry,ce_submitter={$MEMBER}\,c_name=links}


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#6374
Avatar
Standard member
Terry is in the usergroup ‘Fan in action’
Okay thank you much. This got me pretty far.

For Quizzes: it looks like sources/hooks/systems/content_meta_aware/quiz.php looks at cms_quizzes and so it doesn't contain information about who took a quiz. I don't see anything else in this folder that talks about table cms_quiz_entries with col q_member. So to gather the data about who took a quiz, I'd need to do something like sources/hooks/systems/content_meta_aware/quiz.php and change the table in it and the fields appropriately and rename it to something and add it to sources_custom/hooks/systems/content_meta_aware/quiz_results.php and then I can…

{+START,IF,{$LT,{$CONTENT_COUNT,quiz_results,q_member={$MEMBER}},1}}
     <p>You should take a quiz.</p>
{+END}

That sounds about correct?
 
Online now: No Back to the top

Post

Posted
Rating:
#6375
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
You shouldn't try to create a content_meta_aware hook for something that isn't going to fit the baseline criteria for what a content category/entry is. For example, a quiz entry doesn't have a title.

You'd be better off customising the symbol or making a new one.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Users online:

Vaiva, John Connor, Philip, gabriel58, ManojSree, deepu_ms

Forum statistics:
  • 1,253 topics, 5,783 posts, 6,946 members
  • Our newest member is Endoflease
Birthdays:
Back to Top