Search

I’m sure I asked that before, I’m sure it was nickdunn who knew the answer … but I can’t find the thread anymore:

I’d like to know the current entry id while displaying a field (context: displayPublishPanel()). If I use print_r($this) I see the correct number as a private variable of context. How do I access this variable?

It’s not what I was looking for but this is working:

        $currentPageURL = $this->_Parent->_Parent->_Parent->getCurrentPageURL();
        preg_match_all('/d+/', $currentPageURL, $entry_id, PREG_PATTERN_ORDER);
        $entry_id = $entry_id[0][count($entry_id[0])-1];

Instead of $this->_Parent->_Parent->_Parent->getCurrentPageURL(); try using

Administration::instance()->getCurrentPageURL();

I’ll look at exposing the Context data in the next Symphony release. It would be a simple matter of having a new function in lib/toolkit/class.administrationpage.php like:

    public function Context(){
        return $this->_context;
    }

And calling it with Administration::instance()->Page->Context()

Thanks Alistair!

Additional question: What’s the best way to get the current entry id in context of appendFormattedElement()?

Okay, found the solution myself:

$wrapper->getAttribute('id');

I’ll look at exposing the Context data in the next Symphony release. It would be a simple matter of having a new function in lib/toolkit/class.administrationpage.php like:

Alistair, it would be great if all field related functions could access the context data.
By the way, Administration::instance() seems not to be available when used in appendFormattedElement().

Alistair, it would be great if all field related functions could access the context data.

I noted this a while back too. Glad to see I’m not the only odd ball!

$wrapper->getAttribute('id');

I discovered this myself today too. Hack!

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