2 users online. Create an account or sign in to join them.Users

Search

Many possibilities if an entry’s id was passed in:

appendFormattedElement(&$wrapper, $data, $encode = false, $mode = null)
prepareTableValue($data, XMLElement $link=NULL)
displayPublishPanel(&$wrapper, $data=NULL, $flagWithError=NULL, $fieldnamePrefix=NULL, $fieldnamePostfix=NULL, $entry_id = null)

Is this possible? It would keep a virtual (no direct user input) field from needing to be saved just to store the $entry_id.

What ya’ll think?

I don’t think I follow…

No worries, let me give you two examples that I’m currently dealing.

  1. I’ve created a field extension that is simply a link to a front-end page. With this link I pass the entry’s ID. I’ve used this technique to create a printable form that brings together several sections. For instance, my members section for a maritime school I work for has a link to a page that has a member’s information, the courses they are enrolled in, and payment history. This information is culminated across several sections but the entry ID ties it all together. I thought of this method after many members had already created their profiles. After installing the extension I had to actually save each members entry just to store the entry ID.

  2. I’m working on a PayPal shopping cart. I’ve created a table for PayPal to interact with via IPN. I would like to create a field that counts the number of transactions and be able to display that number as a field in the backend and via data source so that one can utilize it to manage inventory.

Hopefully the two examples help illustrate why. Perhaps I’m doing this wrong…? But I have lots of ideas for fields that don’t require any actual user input. Its value is defined by the entry itself or other fields in the entry.

If appendFormattedElement passed the entry_ID I could make this type of field information available to a data source. And if prepareTableValue and displayPublishPanel this type of field could display the appropriate information in the admin.

A while ago that we started adding $entry_id to the relevant functions in the field API, not a conscious process, it was just happening. But just recently I realised that every time an entry ID is passed to a field – there’s already an entirely prepared copy of that entry in existence.

So perhaps we should be passing the entry itself? Wouldn’t that be simpler?

So perhaps we should be passing the entry itself? Wouldn’t that be simpler?

Very much so, I think. It would make for less code in one example because I would have to use the entry ID to look up one of its other fields. Passing the entry itself would offer much more. Any drawbacks?

How difficult is it to implement?

Not hard - I think that perhaps instead of passing the entry ID to each function it’d be better to pass it to the field when it’s constructed.

All you have to do to know if you can reference an entry from any function in a field would then be:

if (!is_null($this->_entry)) {
    // Do entry related stuff...
}

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details