Search

Hi!

I am working on a custom "nested" event based on this tutorial by brendo...

Anyway. The second event always needs to update an existing entry, but I have no idea how to get the url-param {$url-project-id} and use it in the event file...

Here's the snipped that's causing headache.

    // Check that this event returned successfully
if($result->getAttribute('result') == "success") {
            $_POST['action']['clients-edit-project'] = 'Submit';
            $_POST['id'] = '1084';
            $_POST['fields']['status'] = 'Contract Pending';
      }

It works fine, but the ID is hardcoded. The ['id'] needs to be the url-param {$url-project-id}

You can access page params using Symphony::Engine()->Page()->_param.

Super! Thanks! This works perfectly:

$_POST['id'] = Symphony::Engine()->Page()->_param['url-project-id'];

Frontend::instance()->Page()->_param or in the upcoming 2.3 release, Frontend::instance()->Page()->Params()

I swear you added an accessor in 2.3 :)

I am having fun with custom events again...

Here's the situation:

Now I have a comments section set-up that has a Select Box Link field linking back to my members section. I want users to be able to create entries in front-end, but I want this to be secure... Obviously, to associate a particular comment with a user, I need to pass along the user ID, but I do not want this to be visible in the page source code. I already have a custom nested event (using techniques discussed earlier), but now I want to use {$member-id} param and post it "silently"...

This is the outtake of my event file:

unset($_POST['fields']);
 $_POST['fields'] = $this->post[self::ROOTELEMENT]['fields'];

 include(TOOLKIT . '/events/event.section.php');

How can I make it so that would posts all the visible fields of the first event and one additional field named 'associated-member' that pulls its value from {$member-id}? How can I do this without defining all the fields one by one? is this possible?

You can just add the field to the $_POST array like

 $_POST['fields']['associated-member'] = Symphony::Engine()->Page()->_param['member-id']

If you need more default parameter logic, you could use the Default Event Values extension. Though you only get the UI for vanilla events.

Another related question: I need to update last-active field...

  $_POST['fields']['last-active'] = DateTimeObj::get('Y-m-d H:i:s');

It is working, but I just wanted to check if it's the right approach

Hi,

I've got a very similar issue. I'm trying to output a $ds parameter in my custom event. I've got a datasource attached to the page that output the id of the entry.

The $ds-my-event parameter is present in my xml debug, but in my custom event it doesn't appear in the Symphony::Engine()->Page()->_param. array .

Is there a way to get this param in my event ?

Thanks for help

Datasources run after Events, so no, you can't access a datasource parameter from within an event.

Thanks Brendo for the answer. I guess I just have to find another way around.

Hello all. I'm having some trouble doing what qnn was able to achieve above. I'm trying to access page parameters inside the load function of an event:

Symphony::Engine()->Page()->_param['url-comment'];

However trying to echo "Symphony::Engine()->Page()->_param" tells me that the _param member is empty (same goes for trying to access the dictionary members I need). Am I missing something here? Is it possible that the _param member not populated before the load function is called?

Ignore my previous post. I figured out the problem. Silly typo in my code. Sorry about that.

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