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

Search

I'm trying to determine if I needed to extend the content.blueprintspages.php file in an extension whether I'd need to write out the whole block of code in the blueprintspages.php file or just the changes? How does this part work? for example:

I'd like to extend the blueprintspages public function __viewEdit() {} code to Appendpagecontent to the pages area. Do I need only include my changes/addtions or do I need to write out the whole block within the viewEdit function in order for it to work?

Checkout the AppendPageContent delegate.

You would modify the $context['form'] XMLElement object, so no you wouldn't rewrite everything.

Thanks Lewis.

Would I also need to include the content.blueprintspages.php file inside the viewEdit function?

The form element is returned including all of the HTML inside the form. Using $context['form'] you can change/append/prepend the changes you need in the actual HTML.

If you're adding additional info or anything that needs additional processing when the submit button is hit, then you'll need to utilize an additional delegate to process your newly provided information via $context['fields'] through the PagePreEdit delegate.

so PagePreEdit would be used if I am submitting data to another table other than the sym_pages maybe? like a textarea table for my own extension. Also is there a known method to appending fields to the array in the html at a specific point? i.e say if I wanted to insert a textarea but have it appear before the events and datasources fields?

so PagePreEdit would be used if I am submitting data to another table other than the sym_pages maybe?

You can do whatever you like. PagePostEdit/PagePostCreate might be preferable as this will only execute if the Page has been (or is about to be) saved successfully. Remember to listen to the PagePreDelete delegate as well so you can clean up if Pages are removed.

Also is there a known method to appending fields to the array in the html at a specific point? i.e say if I wanted to insert a textarea but have it appear before the events and datasources fields?

AppendPageContent and then use the $context['form']. This value is an XMLElement and using getChildren() you can see that it has other XMLElement objects that represent the fields on the result of the page.

What you want to do is insert your XMLElement object before the last one, and from Symphony 2.2.2, you can do that with insertChildAt. This function supports negative indexes, so by doing XMLElement->insertChildAt(-1, $your_xmlelement), you can put your XMLElement before the events and datasources fieldsets.

Ahh nice one! that's really neat. thanks guys! Excited to get my hands dirty now :) woop!

Edit

Just one more thing. If I am adding this capability in an extension, am I righ tin thinking in order to extend the functionality of the blueprintspage.php file I could be working in a content/manage.new.php and content/manage.edit.php structure within my extension right?

If I am adding this capability in an extension, am I righ tin thinking in order to extend the functionality of the blueprintspage.php file I could be working in a content/manage.new.php and content/manage.edit.php structure within my extension right?

It really depends on what you're trying to do.

  1. Do everything through delegates.
  2. Do everything through admin content pages.
  3. Do everything with a combination of the two above.

Each provide different degrees of implementation and flexibility. I always try to do everything through delegates before thinking about adding content pages.

If you needed to create a content page to manage additional functionality then you would place the file in your extension content folder and name it like content.pagename.php. Inside this file you'll have a class named contentExtensionNamePageName() which extends the AdministrationPage() class. Most content pages have a __switchboard() which determines what content to display and what action to take.

To get an idea of what one of these pages really looks like, it might be easier to take a look at one of my older extension's content page.

Edit: The linked extension above has not been updated but the methods and much of it remains the same.

Thanks Lewis, I'm thinking all through delegates anyways.. just wanted to know what most would use in this situation. No additional functionality is being required other than appending a textarea to Blueprints > Pages via the methods described above. So a backend page isn't needed (if I can add,edit and delete entries in my own extension table via delegates in the main extension.driver file).

I've got the extension creating a new table with the relevant fields and I also have a Preferences fieldset to select if a text formatter is to be used.. Code I've sort of taken from the Documenter Extension.

What I am after, I've already achieve with hacks to the core, so this is now a means to provide the same functionality without messing with core build files.

Thanks for the link will take a look tonight.

Cool, you should have no problem just using delegates. Don't forget to watch PagePreDelete so that you can delete the relevant entries from your custom table, as suggested by Brendan.

Is it best practice to not append any table fields to the sym_pages table? I'm just wondering if there's a convention in the group that tends to avoid altering table fields in here and better to populate an extensions own table with content instead?

Got my Text Formatter and WYSIWYG up and running now it's time to saving the data.

Hey Lewis, Brendo,

What's the best way to mix the insertion of the $fields array so that I can post the contents of $fields['content'] into my extension table and the rest of the fields into the sym_pages table as usual?

Is it a similar convention to events? i.e $fields['myextensionname']['content'] and then $fields['title'] etc.. for normal sym_pages insertion?

EDIT GOT IT! Table is populating with textarea content woop! might release this in a week of so if people were interested.

I have a setting in preferences that appends the relevant class to the textarea for the different textformatters installed.

Next approach is how to add the right scripts and stylesheets to the head of the page depending on the chosen textformatter.

Could someone in the know, direct me to the relevant method for ensuring the text formatter renders to the page correctly? is it TextFormattersManager class?

Looking at Craig's Documenter plugin and his content.new.php file for a hint, but not 100% what I'm looking for yet.

The textarea field provides an example:

            $tfm = new TextformatterManager($this->_engine);
            $formatter = $tfm->create($this->get('formatter'));

            $result = $formatter->run($data);

Change $this->get('formatter') and $data and include class.textformattermanager.php.

Hi Lewis,

Thanks for helping here, much appreciated.

Could $this->get('formatter') be replaced with Symphony::Configuration->get() method to retrieve the slected text formatter saved in the config then?

And could I then therefore place the $tfm code from above into my AppendPageContent Delegate?

Could $this->get('formatter') be replaced with Symphony::Configuration->get() method to retrieve the slected text formatter saved in the config then?

Yup, as long as Symphony::Configuration->get() represents the handle of the textformatter.

And could I then therefore place the $tfm code from above into my AppendPageContent Delegate?

Yup.

Hi Lewis,

If you get a moment could you cast your eyes over my appendPageContent attempt in this pastie? http://pastie.org/3169043

I have text area appearing but not class is added to the textarea node and not formatters are rendered to the Edit or New page entry.

Would appreciate a little nudge, even if it was a pointer to where I need to be looking.. do I need to use notifyMembers for anything in this instance?

Add the class when you create the textarea:

$textarea = Widget::Textarea('textarea[content]', 20, 50, General::sanitize($content), array('class' => $textareaprefs));

Also, $result = $formatter->run($textarea); should be passed raw data, not the textarea object.

See where that gets you...

Hi Lewis, Class added and outputs as expected thanks.

When you say raw data, do you mean the value of the textarea or something else? whenever I change it to anything other than a XML element that is a child of the form, It throws an error.

To be clear, this method is used to render a WYSIWYG to the textarea right? if a text formatter is installed and enabled right?

Cos I'm not seeing any js or css for the relevant text formatter being added to the page head.

What you probably want is the addScriptToHead or addStylesheetToHead functions which allow you to inject those files into the <head> of the backend.

The InitaliseAdminPageHead delegate is what extensions usually hook into to add external scripts/styles.

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