Search

This field extends the existing Number field by incrementing the field value by one every time the field is returned in a Data Source XML. This is useful for storing counts of views of pages or articles on your site, to allow for ‘sort by popularity’ functionality or basic page view statistics.

A new entry will provide a default value of zero. The value will increment every time the field is output by a Data Source. If you do not wish a Data Source to touch the value, simply do not output the field. The value can be amended at any time.

Note: this field requires the Number field to be present in your /extensions/ folder, but not necessarily installed (it simply extends the Number field class).

Increment Number field on Github

Dynamite. Not only is this awesome functionality, but I expect we can study this for lessons on how to extend field extensions as per this discussion

Now if only the number field didn't conflict with Rowan's reflection field...

I've got looked at the Reflection field. Do you know what conflict arises?

For me, reflection field works fine unless the section also contains a number field. If it does, regardless of whether the number field is even given a value, you get an error when you try to save the entry. I'll dig up the particular error in a moment... The number field doesn't even have to be part of the reflection field's formula either.

The Error

 Fatal error: Call to a member function appendFormattedElement() on a non-object in /home/cz/Development/Server/symphony-2/extensions/reflectionfield/extension.driver.php on line 97

This is using a slightly modified version of Reflection Field that I changed to retain compatibility with selectboxlinkfield and others and to allow you to hide the field during entry creation, but I'm 99% sure I had this problem with a vanilla copy of RF too. Will double check.

How odd. If this is a problem with the Number field then fixing it there may well fix it on the Increment field since it extends Number. I haven't got time to look into it now, but I'll add it to my list. I've not used the Reflection field yet, so this will be motivation to give it a go.

Will be eternally grateful if you can squash this particular bug. And thanks for the flurry of great extensions and such. You must have had a very productive week!

Just a note... it appears that the number will also increment whenever the entry is edited. Just FYI for people using it to track views and such.

Edit Scratch that. That's only happening with one section... Looking into it.

Just a note: If you use this field in a section in conjunction with Rowan's Reflection Field, it will also increment whenever the entry is saved. Not a big deal, but worth knowing.

Anyway around this?

Not really. This field requires a bit of a hack to work and I don’t really have the time to fix it. I think it needs to check the context in which it is being run: if it’s through the Frontend then increment, but if it’s called when the parent is the Administration object then don’t increment.

That’s what I’m after! whenever your able to tackle this…that would be sweet. :)

Client is accepting this for now!

moonoo2

Is there a way to add the views to the with selected link in the entry admin panel?

Would like the option to reset all views to 0 if I wished..

Good suggestion. I’ll add it to the growing list…

:-)

I couldn’t even stand to see your list. Too much for me.

Dude, appreciate all you do here!

Just a novice trying to get to grips with this thing.. I’m holdingon by the horns and bracing for the big jolt forward!

It’s a thought that would make the reset clear for an administrator to monitor a fresh set of posts from a given date!

cheers moomoo2

Moonoo, I’ve updated the Increment Number field with two changes:

Increment Number field 1.1

  • only increment number when called through a Data Source (fixes conflict with the Reflection field)
  • added a “Reset to 0” option in the With Selected drop down to reset selected entries to 0

Just overwrite the existing folder with the one above and re-Enable.

Craig, I’ve fixed the bug whereby the value increments with the Reflection field. However I’m unable to replicate your PHP error. Considering your bug report is now almost a year old (I should really update extensions more often!) I’ll consider it case-closed: a ton of stuff has changed since.

Yeah, I didn’t even remember it. If I’m not mistaken, it was a problem with number field itself, and has since been fixed.

Ohhhh maaan nickdunn.. you have made my early day so worth while!

Thanks for listening!!

moonoo

Notice it does not increment in the admin panel when you save or edit an entry! sweet!!

moonoo

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