Search

Hi,

Can someone explain (or give an example) how to create an extension in Symphony 2 that outputs something to the frontend? I can’t seem to figure it out. Any help is great, thank you.

I'm also curious about building out extensions. are the 1.7 docs for the CS api somewhat similar to how extensions are built in s2?

*bump =)

I guess the main problem is that the extension API is not yet finished and accordingly not yet feature complete.

But - indeed - it would be great to know more about the feature set available for extensions at the moment. I have been looking through the code of the published extensions and as I'm not a PHP professional I have to admit that I do not understand the full functionality as is. I quite like the example campfire service available for 1.7 which featured the scope of possibilities. Maybe we can get something similar for Symphony 2?

From what I've gather thus far on extensions is that they are still pretty similar to CSes in 1.7. I think it was alistair that said it's not too difficult to convert a CS to an extension. Like yourself, nils, i am not a php dev, but i have been trying to figure out the similarities and differences to try and modify/create a simple extension. So far, i've only come to understand delegates and how they relate to the extension. but not actual implementation of things.

You can do much more in 2 with extensions than you could with campfire services in 1.7. Much has to do with changes to the core itself. It would be best to have specific questions put forth to better help you, and also shape documentation.

Can someone explain (or give an example) how to create an extension in Symphony 2 that outputs something to the frontend?

What specifically are you trying to do? Creating extensions for the front end is usually as simple as creating an event, data source, or field type, and following the folder structure.

There will be some major code revisions for Rev 6 that will effect how Extensions are implemented (The API will remain more-or-less the same). There are a lot of very confusing object relationships in the pre-rev6 code base that makes the learning curve and maintenance of Extensions difficult. An example would be the crazy $this->_Parent thing that has existed since Symphony 1 beta. Transitioning to PHP5, we have been able to totally replace it with the use of Singletons.

So, once Rev 6 is out I will be doing some basic examples and documentation since the core code will be less likely to change and everything will be much easier to explain.

thanks for the update, alistair.

I was trying to do two extensions. One was converting the Session Monster CS to an extension and another is to just increment a number in the database from a flash call.

should I wait until you come out with rev6 to develop any extensions since you're saying the core will change from rev5 to 6?

For what you mention, I don't think you will run into any problems between revisions.

converting the Session Monster CS

This one is a combination of an Event, to register any new items into the session, and a Data Source to put any existing data into the page XML.

increment a number in the database from a flash call.

Sounds like something an Event could handle.

Both of those should be relatively easy to do.

increment a number in the database from a flash call.

this event would basically open up the db directly and increment whatever field i indicate, right?

Sure. That would work.

$this->_Parent->Database->query("UPDATE `sym_blah` SET `fieldname` = `fieldname` + 1 WHERE `something` = 'value' LIMIT 1");

That would be the basic idea. This would get run from the __trigger() function of your Event.

Hi,

Sorry for the late reply. I was on a nice vacation.

I like to build pages with a user subscription and all sorts of nice functions. Like facebook for example. So it’s difficult to highlight one function.

The thing that is also not clear to me is; when should I choose to build a function in an Extention and when in an Event.

A simple extension that output’s “Hello World” to the front end will be great. That will already explain the concept.

Thank you.

when should I choose to build a function in an Extention and when in an Event.

Well, an Extension is a way to logically group a bunch of Events, Data Sources, Text Formatters, Fields and Admin interfaces into a single package. It gives you more flexibility than, say, a standalone Event. For instance if your Event stores data in a custom table, than you need away to create the table. Having your Event check the table exists every time it is fired really isn't ideal. Also, when the Event is removed, it isn't able to clean up after itself. An Extension has an install() and uninstall() function which is fired via the Admin Extensions interface.

A simple extension that output’s “Hello World” to the front end will be great. That will already explain the concept.

As already mentioned, there are a number of aspects to an Extension, and ultimately it is a container for other functionality.

I will see if I can come up with something tomorrow to demonstrate some of the important parts of an Extension.

Hi Alistair,

That will be very helpful. Thank you.

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