Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • lucuma 261 posts 563 karma points
    Nov 18, 2010 @ 23:22
    lucuma
    0

    Datatype or Maybe something else?

    I'd like to build something although I'm not entirely sure if what I want to do is the correct approach. Maybe someone can either point me in the right direction or tell me what I'm trying to do is stupid and won't work.  Here goes:

    1.  Create a data type called TextoBitly.  One of the parameters will be the name of a field like bodyText and the api credentials.

    2.  Add this data type to a document that has a bodyText property.

    3.  Upon publish (or save), it would regex search the bodyText property for hyperlinks and call bitly to shorten them.  It would then modify the link in bodyText with the shortened link.

    4. Bonus - Create a lists of links that were shortened under the node....

    Does this process sound right?  Is a Data Type the right way to go here?  #4 really is optional for me as I'm just using this to learn.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 19, 2010 @ 14:28
    Tom Fulton
    0

    Hi,

    I think that could be done, but there isn't really a need for a Datatype, this would all be done via Events.  The only reason you'd need a datatype is for #4, if you want to store/show a list of the links that were shortened on that node.  You could store your parameters in a config file in /config or in web.config.

    Here's some basic info & examples on events to get you started:

    http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events

    http://www.richardsoeteman.net/PermaLink,guid,f470b6cf-40da-4aa9-a0d9-7b984fe9bf59.aspx

     

  • lucuma 261 posts 563 karma points
    Nov 19, 2010 @ 20:29
    lucuma
    0

    Hey Tom, thanks for the response... That's what I ended up doing and it was really easy to use an event to bitly all external links in the bodyText especially with the html agility pack.  I may do step 4 with a regular document that only has two textstrings on it just to figure it out and build a report for the dashboard that pulls the stats.. We'll see how that goes.

Please Sign in or register to post replies

Write your reply to:

Draft