getLastNumberInUrl remove fields

9 posts by 4 authors in: Forums > CMS Builder
Last Post: January 21, 2016   (RSS)

In the viewer functions->getLastNumberInUrl there is a remove fields array for 3rd party field value pairs.

I hacked the array to add one that I need "USER_AGENT" added by 3rd party script. Is there an easy way to add fields without modifying the view_functions directly?

Jeff Shields

By ross - January 15, 2016

Hi Jeff

Thanks for posting!

I see what you mean and at this time there is no way to edit that.  I'll bring this up with the dev team and see if that's something we can make easier.  

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

I don't have control of the 3rd party adding its value, so that doesn't work. It would be nice if we could configure getLastNumberFromUrl to add additional values pairs to ignore/

Jeff Shields

By Dave - January 19, 2016

Hi Jeff, 

We'll add a plugin hook for an upcoming release to let you modify/extend the $removeFields list.

We could also look at having an option to parse out the first number in the URL (after the ? but before &).  Let me know if that would be helpful.

And for more complicated sites sometimes it makes sense to just have a little custom code to parse out the number.  Especially if you want to customize the urls to appear in a way that is different from what CMSB does by default.

Hope that helps, let me know any questions or what would work for you.

Dave Edis - Senior Developer
interactivetools.com

I like the hook idea, makes it much easier to extend with third party apps. I am using tectites formmail for email handling as it is very advanced in many areas and with their hook system easy to integrate with CMSB.

Jeff Shields

By Dave - January 20, 2016

Hi Jeff, 

Ok, I've added a plugin hook/filter called 'getLastNumberInUrl_removeFields' for the next release

Here's some example code: 

// test.php
// Usage: test.php?article-title-123&something-new=456

addFilter('getLastNumberInUrl_removeFields', function($removeFields) {
  $removeFields[] = 'something-new';
  return $removeFields;
});

print getLastNumberInUrl(0); // should output 123

We should have 3.01 out very soon.  Let me know any questions once you've had a chance to try it out.  Thanks!

Dave Edis - Senior Developer
interactivetools.com

I take it that this can go anywhere and doesn't need to be an add-on.

Jeff Shields

By Dave - January 21, 2016

Yea, it can go anywhere, but if you need to call it on more than one page it would probably make the most sense as a plugin.

Dave Edis - Senior Developer
interactivetools.com