Search

Is there a way to limit the amount of entries within a section?

I have a situation where I have a JavaScript carousel and the client can only have up to 6 slides. They often enter more then 6 entries into this section and then complain that they can't see their latest entries. I have explained that they can reorder the entries, and only the top 6 published entries will appear but it seems to have no effect.

I have also limited my DS to the top 6 published entries. I think being able to limit the amount of entries in the first place would be an ideal solution in this instance.

Are your clients creating the entries using the backend or the frontend? If the frontend, check the current entry count and just don't display an entry form if the count is 6 (or greater); display a message instead. You will, of course, have to have a data source that provides any section field to enable you to get the count.

My client is using Symphony's admin to edit their entries.

Looks like you need a custom extension. You can write some JS into the head which counts the number of rows in the table and hides the Create New button if you're over a certain threshold.

Looks like you need a custom extension. You can write some JS into the head which counts the number of rows in the table and hides the Create New button if you're over a certain threshold.

All this work could be avoided if the client would simply understand what you explained him :)

I too would like to accomplish this. There is not a lot of documentation on any of this. Can any one provide a tutorial on extensions for newbies like me!!.. and by the way.. Symphony Rules!! Ive been cracking extensions open and staring at the code as well as the API docs. I'd rather prefer someone wrote a hello World extensions tutorial or some kind of 101. Or explain it to me and Id write the tutorial. :) The symphony book deosnt hit the stores till August. I dont think I can wait that long...

The symphony book deosnt hit the stores till August

And it's not about the current version of Symphony either ;o)

A Hello World example would be in the form of other extensions that do similar things. You want to append some JavaScript to the backend there are many extensions that do this, so Publish Filtering is one such example. You'll then need to write the JavaScript to achieve the functionality yourself (jQuery), which no documentation can accommodate.

Which bit do you need assistance with?

Has someone already done this?

While not exactly what was asked for, you could use the Unique Checkbox Field to only allow '6' (or however many) entries to be marked as published at a time. You can also configure the field to 'steal' the checked status from other entries, so if they add a seventh entry, and tick the box, it will remove the 'published' status from the oldest (I presume) field. I use it all the time for feature sliders etc.

It also means that the client doesn't have to go through the pain of trying to add a new one, realising it's limited, going back and removing an old slider, then adding the new one. And if they ever want to re-enable an older slide they don't have to re-upload it.

@Henry: Thanks for pointing out this extension. If I cant`t get my head around how to hide the create button. I may give this a try.

I recently ran often into these kind of problems. Mostly when having some kind of "intro" section (one entry) linked to a subsection (select box link) with all the entries in it. In the past I've used meta_section for this but it seems to be broken. Using only a static section isn't an option because I wouldn't be able to access the select box linked entries...

ps: Sorry for hijacking the thread.

You can write some JS into the head which counts the number of rows in the table and hides the Create New button if you're over a certain threshold.

I managed to write some code which hides the "create entry" button if there are 6 or more entries

$(function() { 

  if($('tbody >tr').length < 6) return;

  $('.create.button').hide();
});

My questions now are:

  1. How do I limit this behavior to a section?
  2. Is there a best practice to add this to the backend?

You can retrieve it via:

Symphony.Context.get('section_handle', 'env');

(check the source of backend pages to see where this env object is set in the <head>.

The easiest way is to use Backend JavaScriptr or Backend add script. So long as these extensions add the code after the above Symphony.Context is set, you can access it.

Thanks Nick! Will try...

By the way had to change $ to jQuery in the above code to get it working in symphony.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details