3 users online. Create an account or sign in to join them.Users
Tip: Don't execute Data Source if a URL parameter is set
This is an open discussion with 8 replies, filed under General.
Search
smart :)
It’s exciting to see this sort of functionality in the 2.1 sneak peek :)
It’s definitely going to be very useful.
Is this going to be added in 2.1 then? This is probably one of the best tips I’ve found on this forum to be honest, thanks to Brian pointing it out!
Brilliant!
This may be a stupid question… Does anybody know if this has been implemented as a feature?
It hasn't but shouldn't be too much work, and very beneficial IMO
Yep, definitely!
Brendan is preparing a general update to the Data Source editor logic and it should be easy to add this feature in this context. We are preparing everything on the interface side in 2.3, the programmatic changes are the next step planed after that, see #894.
Create an account or sign in to comment.
I’ve been using this quite often lately and this is certainly something that is useful for others:
Symphony offers a simple way to execute data source only if a required URL parameter is set. But from time to time you want to achieve the contrary and stop data source execution if a parameter is not set. With a small data source customization this is possible. Add this line to your
grab()function replacingNameOfYourURLParamwith the parameter name that should be checked:Like so:
public function grab(&$param_pool=NULL){ $result = new XMLElement($this->dsParamROOTELEMENT); if(!empty($this->_env['env']['url']['title'])) return $this->emptyXMLSet(); try{ include(TOOLKIT . '/data-sources/datasource.section.php'); } catch(FrontendPageNotFoundException $e){ // Work around. This ensures the 404 page is displayed and // is not picked up by the default catch() statement below FrontendPageNotFoundExceptionHandler::render($e); } catch(Exception $e){ $result->appendChild(new XMLElement('error', $e->getMessage())); return $result; } if($this->_force_empty_result) $result = $this->emptyXMLSet(); return $result; }This will return an empty XML element if the parameter
titleis set.Finally change
allowEditorToParse()to returnfalsewhich will prevent the data source editor to edit your data source again and override your changes.