Skocz do zawartości
  • Zarejestruj się
Zaloguj się, aby obserwować

[] The Development Channel - 4.0 - Sharelinks

Polecane posty

We refer to the icons you can use to post to third party services such as Facebook, Twitter and Digg as "Sharelinks" in our software suite, and we consider these an important tool both for community promotion and for search engine optimization.  Not only can you get links to your community out there on other large, popular sites on the internet where you might be able to drive back more traffic to your own site, but search engines will also see these links to your site on the other large popular sites, follow them, and rank the pages they reach accordingly.
Share links were supported in 3.x, however while planning 4.0 we felt that the implementation could be improved, and so we've done just that.  We have tidied up the interface to make managing the services easier for the average admin, provided more flexibility for third parties who wish to developer additional share link services, and we've made it much easier to use from a development stand point.
Managing Sharelinks
Within the admin control panel, you must be able to manage the sharelink services that are available.  You may only want to offer buttons to share to Facebook and Twitter, removing clutter that you don't feel your community is familiar with.  Or you may want to enable every share service link possible, because your community is full of technical-oriented users who will make use of them.  Wherever you fall within this spectrum, the process should be simple and straightforward.

We have removed the ability to add and delete sharelinks, because the reality is most services require far more integration than simply specifying a URL.  Thus, we have made the system plugin-based, which allows developers who are familiar with the process far more control, while greatly simplifying the interface for the average administrator.  If you are comfortable with adding a link and an icon, building a plugin (see below) is a very simple process.  Otherwise, if you don't know what an "HTML" is, you will now be able to work with this page in a far easier manner.
There is a generic settings button at the top, which allows you to globally enable and disable share links, as well as specify whether you want users to have the opportunity to automatically share links to new content with supported services.  When you choose to "Edit" a given service, you can specify which groups can access that share link, and specify any service-specific settings related to that service (for instance, to change the default Twitter hash tag used when sharing via Twitter, you would click to edit the Twitter service).
Integrating a New Service
While we ship with some of the most popular services already supported (including support for LinkedIn sharing, new in 4.0!), it is a very simple process to add support for new services.  When you build a new sharelink service and drop it into the appropriate folder, it will automatically be installed as soon as you visit the sharelinks management page in the ACP, where you can then choose to enable/disable the service and configure any available options.  If you delete a plugin file, the service will automatically be deleted again when you visit this page in the ACP.  No further interaction is required to install or uninstall a service, other than visiting the management page in the ACP.
The basic template for a plugin file is as follows


namespace IPS\Content\ShareServices;

class _Servicename
     * @brief    URL to the content item
    protected $url        = NULL;
     * @brief    Title of the content item
    protected $title    = NULL;

     * Constructor
     * @param    \IPS\Http\Url    $url    URL to the content [optional - if omitted, some services will figure out on their own]
     * @param    string            $title    Default text for the content, usually the title [optional - if omitted, some services will figure out on their own]
     * @return    void
    public function __construct( \IPS\Http\Url $url=NULL, $title=NULL )
        $this->url        = $url;
        $this->title    = $title;

     * Add any additional form elements to the configuration form. These must be setting keys that the service configuration form can save as a setting.
     * @param    \IPS\Helpers\Form    $form    Configuration form for this service
     * @return    void
    public function modifyForm( \IPS\Helpers\Form &$form )

     * Return the HTML code to show the share link
     * @return    string
    public function __toString()
        return "<b>Some HTML</b>";

The class name "_Servicename" should be the same as the filename, minus the _ (the underscore is part of hooks and plugins system in 4.0, which you can read about in the relevant blog entry).  So this filename would be "Servicename.php" and would be located in /system/Content/ShareServices/.  The modifyForm() accepts a reference to the form object that is displayed when configuring the service.  Here, you can add new configuration options that will be saved automatically (the configuration options should be settings).  If you need to specify any HTML or CSS that needs to be manually loaded for the service, you can add assets to both the <head> of the document, or insert content right before the closing </body> tag, depending upon the service's needs in the constructor.  The __toString() magic method should return the HTML necessary to generate the share service link.
It is really that simple - there are no hidden "gotchas" to watch out for.
As an aside, the built in ability to email a link has been greatly simplified for third party developers as well.  If you implement third party applications by extending the appropriate classes (which we will blog more about later), the ability to email a link to your page with permission checking built in will all be handled automatically for you.  You don't need any plugin files specifically to facilitate emailing links to your content items in 4.0.
Implementing Sharelinks in Applications
To implement the sharelinks in your third party applications is equally simple.  As mentioned above, assuming you extend the appropriate classes to generate content items (which will be blogged about in detail at a later date), you need only do two things to implement share service integration in your application.
First, your class that extends IPSContentItem must implement the interface IPSContentShareable.  This automatically enables the share links in your application and adds support for any functionality the share services utilize.
Second, your template should include the appropriate sharelinks template where-ever you wish to display the share links
{template="sharelinks" group="global" location="front" params="$contentItem"}

If you wish to render the share links in some manner beyond our default generic rendering, you can simply use whatever HTML you need to, however we feel that most content items can utilize our generic template just fine.
A Few Notes in Closing
We feel that these changes will make implementing share links as easy as possible while still providing you all the flexibility you may need to customize the interaction and display of the links at every level.
We have also decided to remove the "print" and "download" share links at this time.  In researching their usage and their functionality, we feel that it is no longer worth maintaining these unnecessary links which simply add clutter to the page.  All browsers allow you to save a page (i.e. download it) already, and all browsers allow you to print a page already.  We will include a print stylesheet with 4.0, just as we did with 3.x, so when you choose to print a page the output will be better tailored for printed media.  We feel, however, that retaining the links adds no real value for the vast majority of users, and is more inline with what most users encounter on other similar websites.
We hope that the improvements and decluttered interface, both on the front end and the ACP, make configuring and using these services (and adding support for others) much simpler than in previous versions.

Attached thumbnail(s)

Zobacz Artykuł w pełnej wersji

Udostępnij ten post

Link to postu
Udostępnij na innych stronach

Bądź aktywny! Zaloguj się lub utwórz konto

Tylko zarejestrowani użytkownicy mogą komentować zawartość tej strony

Utwórz konto

Zarejestruj nowe konto, to proste!

Zarejestruj nowe konto

Zaloguj się

Posiadasz własne konto? Użyj go!

Zaloguj się
Zaloguj się, aby obserwować  

  • Kto przegląda   0 użytkowników

    Brak zalogowanych użytkowników przeglądających tę stronę.


Ważne informacje

W celu świadczenie usług przez nasz Serwis na najwyższym poziomie, w ramach Serwisu wykorzystujemy pliki Cookies (tzw. ciasteczka). Korzystając ze stron Serwisu IPSBEYOND.PL bez zmiany ustawień przeglądarki będą one zapisane w pamięci urządzenia. Jeżeli nie dokonacie Państwo zmiany ustawień przeglądarki internetowej to wyrażacie zgodę na zapisywanie plików Cookies.