Copied to clipboard

Flag this post as spam?

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


  • William Burnett 213 posts 262 karma points
    Sep 11, 2009 @ 17:22
    William Burnett
    0

    Macro to insert Raw script blocks

    please forgive my ignorance...

    I wish to be able to insert raw HTML into page content for the purposes of affiliate advertising, banner ads, etc.  I understand how to add code to templates, but not to individual pages from within the editor. Raw HTML editing is out of the question.

    I would imagine this can be done via an XSLT or other script macro?  For example Amazon affiliate links are iframe.

    Thoughts?

  • dandrayne 1138 posts 2262 karma points
    Sep 11, 2009 @ 18:02
    dandrayne
    0

    Hi There

    You could perhaps create a macro with a single paramater of type "textMultiLine", then output it with xslt while using

    disable-output-escaping="yes"

    Remembering to disable rendering in the editor. 

    Worth a shot!
    Dan

     

  • William Burnett 213 posts 262 karma points
    Sep 11, 2009 @ 18:26
    William Burnett
    0

    I will give it a try right now dan... my XSLT skills are quite limited (I can alter the code of others, but don't know the structure well enough to write my own yet).

     

     

  • William Burnett 213 posts 262 karma points
    Sep 11, 2009 @ 19:31
    William Burnett
    0

    No luck

    <xsl:template match="/">
    <xsl:value-of select="/macro/rawCode" disable-output-escaping="yes"/>
    </xsl:template>

    Does not work. When I click on the macro after SAVING the page, the multiline text is edited. It appears that the first set of double quotes causes a problem.

    There has to be an easy way to do this.

    <iframe src="http://www.someurl.tld"
    width="120"
    height="60"
    scrolling="no"
    border="0"
    marginwidth="0"
    style="border:none;"
    frameborder="0">
    </iframe>
  • Ron Brouwer 273 posts 768 karma points
    Sep 11, 2009 @ 19:55
    Ron Brouwer
    0

    The content passed to a macro is always set between two quots so it is never posible to pass quot's into a macro.

    What did you mean by Raw HTML editing is out of the question?

    That you do not want to use a richtext editor?

  • William Burnett 213 posts 262 karma points
    Sep 11, 2009 @ 20:43
    William Burnett
    0

    The richtext editor is fine. But clicking the "HTML" button and trying to insert code on the page is very clumsy and unmanageable at best I would like a way to simply drop code snippets into the richtext editor.  That is, I have a need for a function or macro  in the sense of "insert script here".

    I hope I have explained myself well.  

  • Ron Brouwer 273 posts 768 karma points
    Sep 11, 2009 @ 20:53
    Ron Brouwer
    0

    Is it nessesary to insert it on any location? Otherwise you can use a textMultiLine property on your page and insert it whereever you want.

    Ron

  • Ron Brouwer 273 posts 768 karma points
    Sep 11, 2009 @ 20:58
    Ron Brouwer
    0

    Another option is to create a folder in your tree with "advertisings" and there you put a specific documenttype that holds your advertising.
    After that you can create a macro that simply puts the advertising in its place.

    Doing so allows you to reuse advertisings as well.

    Ron

  • William Burnett 213 posts 262 karma points
    Sep 11, 2009 @ 21:07
    William Burnett
    0

    Yes, the items need to be inserted just as you would an image or other page element.  If I use the Multiline Text property of the document, I must edit the template to change the placement of the item (or am I missing something again), and I need to create multiple text property boxes in the document definition, 1 for each "code item".

    In other editors (be it frontpage, dreamweaver, etc) there in "insert script" button or buttons that simply insert the desired script (be it iframe, java, basic, whatever) at the desired location.

     

    Bill

     

  • Ron Brouwer 273 posts 768 karma points
    Sep 11, 2009 @ 21:11
    Ron Brouwer
    0

    Had you already seen my last reply when you wrote this?
    I think thats the best solution in your case.
    Especialy when the script changes it would be nice to be able to change it in one location.

    Ron

  • William Burnett 213 posts 262 karma points
    Sep 11, 2009 @ 21:55
    William Burnett
    0

    Thanks Ron... I had not seen the response when I posted.  I am not real clear on the steps needed to get this setup.

    I understand that I need to create:

    1. a Document Type called "Advertising Folder"
    2. a Document Type called "Advertising Script"
    3. Add "advertising script" to the allowed child nodes of "advertising folder"
    4. create a "Multiline Text" field for the "Advertising Script" document called "adCode"
    5. create a document template for the "advertising Script" and insert the"adCode" text field
    6. not sure what to do next.

    I tried to create a macro with a media picker to insert the slected "advertising script" media, but I don't seen any results.

     

  • Ron Brouwer 273 posts 768 karma points
    Sep 12, 2009 @ 12:28
    Ron Brouwer
    0

    Step 5 is not correct.

    You should create an xslt that takes a param `advertisementScriptId` and selects the script:


    <xsl:param name="advertisementScriptId" select="//advertisementScriptId">

    <xsl:variable name="advertising" select="umbraco.library:GetXmlNodeById($advertisementScriptId)"/>
    <xsl:value-of select="$advertising/data[@alias='adCode']"/>

    the Macro take the same param 'advertisementScriptId' as a contentpicker. and the checkbox 'use in editor' shoud be on. 'Render content in editor' should be off.

    Now you can insert it into your editor and you only have to select the script you want.

    Ron

  • Ron Brouwer 273 posts 768 karma points
    Sep 12, 2009 @ 12:32
    Ron Brouwer
    0

    the advertisement folder and the advertisement script both do not need a template

    Ron

  • William Burnett 213 posts 262 karma points
    Sep 12, 2009 @ 15:15
    William Burnett
    0

    Thanks for the clarification. I will give it a try this afternoon and let you know how it turns out.

  • William Burnett 213 posts 262 karma points
    Sep 13, 2009 @ 05:06
    William Burnett
    0

    Thank you for the help. It all appears to work with your assistance. While I don't think the solution is ideal (I don't like the idea of all of the extra nodes bogging down XSLT sorts, etc) It will suffice for now. I have added the umbracoNaviHide field to "folder" and all of the advertisement children.

    Is there any problem with allowing the code to render in the editor other than it creating an active hyperlink?

     

     

  • Ron Brouwer 273 posts 768 karma points
    Sep 14, 2009 @ 09:53
    Ron Brouwer
    0

    If you put the advertisement folder outside your website it won't slow down at all.
    Then it won't be added to your site xml.
    That is also the reason why I use "umbraco.library:GetXmlNodeById"

    Please select a solution so this item can be closed.

    Ron

Please Sign in or register to post replies

Write your reply to:

Draft