I'm trying to determine if there is a method to override a setting from the configuration array on a temporary basis? i.e. Backend Section index pages.

Was looking to fix up the order entries issue when there are loads of entries in the section, the backend is taking ages to load. Seems the Order Entries extensions changes the 'paginationmaximumrows' to '99999' but doesn't change it back at all.. so I'm trying to determine if there is a method in the core to override the section index pagination if order_entries is the chosen filter.

You might try something like this:

 * Before generating the amdin page, manipulate Symphony's
 * configuration array.
 * @uses AdminPagePreGenerate
 * @return void
public function adminPagePreGenerate($context){

    $callback = Symphony::Engine()->getPageCallback();
        // some funny conditions
        $callback['driver'] == 'publish'
        && $callback['context']['section_handle'] == 'lalala'
        // params are: name, value and group
        Symphony::Configuration()->set('foo', 'bar', 'lululu');

But I must admit that when I tried this once, it didn't work. I assume (but I am not sure) that it had to do with a "timing problem" witht the Members extension. (I wanted to change the Members configuration.) So please try it and tell us if it works for you!

Ah, and you will need to subscribe to the delegate, of course:

 * Delegates to subscribe to
 * @return array
public function getSubscribedDelegates(){

    return array(
            'page'      => '/backend/',
            'delegate'  => 'AdminPagePreGenerate',
            'callback'  => 'adminPagePreGenerate'

Thanks for your input Michael.

Does this save the change back to the config though?

Because I'm trying to avoid that scenario? setting the value surely saves it back to the config.


Michael-e, I think it works now :) thank you: Ignore the oldish code conventions for now... will change these out.

        public function adminPagePreGenerate($context)

        $page_callback = Administration::instance()->getPageCallback();
        $page_callback = $page_callback['context'];

        if(isset($page_callback['section_handle']) && $page_callback['page'] == 'index'){

            // find sort settings for this section (sort field ID and direction)
            $section_id = SectionManager::fetchIDFromHandle($page_callback['section_handle']);
            if(!$section_id) return;

            $section = SectionManager::fetch(SectionManager::fetchIDFromHandle($page_callback['section_handle']));

            // we only want a valid entry order field and ascending order only
            if ($section->getSortingOrder() !== 'asc' || !is_numeric($section->getSortingField())) return;

            $field = FieldManager::fetch($section->getSortingField());
            if(!$field || $field->get('type') !== 'order_entries') return;

            $section_id = SectionManager::fetchIDFromHandle($page_callback['section_handle']);
            $count = Symphony::Database()->fetchVar('total', 0, 'SELECT COUNT(*) AS `total` FROM `sym_entries` WHERE `section_id` = '.$section_id.';');



Might be a nice fix for the Order Entries field.. what do you think? It overrides with the total count of entries in the section if Order Entries is the chosen filter if not this function doesn't run so the Config takes the default value.


Well it was working.. now it does not :(. I set the config 'paginationmaximumrows' to '1' to check if I can override with section entry count total and it just returns 1 entry per page intead of all of the entries.. if I var_dump() the configuration() object I see my change, but it isn't influencing the pagination change of the actual resolved backend page.

Maybe @brendo can shed some light on this...

I added a __construct function in the extension and tried to set the pagination in there.. but this does save over the entry in the config.. so no joy as of yet.

Right, totally stuck here... I'm trying to determine at what point the 'backend' page retrieves section entries to the 'viewIndex' page. Clearly this happens before adminPagePreGenerate delegate because it doesn't seem to influence the change in the configuration object even though I can see this change when inspecting the output variable.

Any pointers where I should be looking?

So, you don't have to worry about overwriting the config file as that only happens when Symphony::Configuration->write() is called.

The config file is loaded as soon as Symphony is started, so if you want to override a particular setting, you can do anytime after that. I believe adminPagePreGenerate is too late though, that's after the page has been built, but it's just waiting to be flattened to HTML from XMLElement.

What if you try your code off the InitialiseAdminPageHead or AdjustPublishFiltering (which is called just before the filtering occurs) delegate instead?

Thanks Brendo, Nicks code originally used the InitialiseAdminPageHead and seemed to save the change to the Config this way...So this got me thinking from what you say, why does the set() function save when it shouldn't. I got a feeling from digging around yesterday that if the user is clicking between different filter types, there is a function setSortingField which gets triggered on change of well.. sorting field.. in turn this saves changes to the config file.. so if any set() actions are performed on the Configuration object, they would be saved no? Just an observation.. maybe set needs an $overwrite flag or something... edge case I know.

Will try AdjustPublishFiltering and see what happens.


AdjustPublishFiltering has solved it! woop, so Order Entries now only changes the paginationmaximumrows to the total for the section if order entries exists in the section and is the current filter selected.

I'm gonna fix this up as a pull request to the repo me thinks.

Thanks for help both!

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