Copied to clipboard

Flag this post as spam?

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


  • philw 99 posts 434 karma points
    Apr 18, 2013 @ 15:40
    philw
    0

    Site wide settings - access for content users

    I'd like my content editors to have access to parameters like email address (which will be obfuscated), telephone number etc, from their content editing.

    I can work out how to add fields to document types, but those change for each document, so those aren't what I want.

    If I add a property to (say) my home page master page, then that's site wide, and I can access it from child master pages thus: <umbraco:Item field="obfuscatedEmail" recursive="true" runat="server"/
    But that's not what I want, because I want this to be usable in content, not in the master pages.

    So I need a way to get to that field from content.... a macro I would think. But I can't see how to access the fields from a macro at all.

    I'm sure you can do this, can anyone emlighten me please?

  • Rich Green 2246 posts 4008 karma points
    Apr 18, 2013 @ 15:44
    Rich Green
    0

    Hey Phil,

    I've re-read that post 3 times, I'm sorry to say, I don't understand what you're asking?

    Are you asking how you get a recursive value in XSLT / Razor?

    Rich

  • philw 99 posts 434 karma points
    Apr 18, 2013 @ 15:53
    philw
    0

    Sorry, but thanks for trying.

    I have a website and it has some site-wide parameters, such as (say) email address. These parameters I want to enter into the system once, as a developer or a content editor. I don't really mind, although if the content editors can enter the values that's easiest for us. Traditionally such values would be in Application.config: they are effectively compile-time constants. The reason to put them in a place like this is that when they change, we can change them in one place, rather than having to hunt through all the content to find all the old values and change them all to the new. 

    ---

    I cannot work out how to set up such a value in a way that a content editor may insert it into their content. I can work out how to set them up and insert them into master pages, but that doesn't really help me: I don't want to use these on every page of a particular type, just one or two random pages.

    I would like content editorsd to be able to insert the value via a macro, or by typing in script, into the content, not into the Master Page.

    This site isn't using Razor, these are straight asp.net master pages. I don't mind if I need to use XSLT, if that's the way to do it. An example would be great (not of how to code XSLT, the issue isn't technical, it's how you do this in Umbraco specifically).

  • Rich Green 2246 posts 4008 karma points
    Apr 18, 2013 @ 16:01
    Rich Green
    0

    Hey Phil,

    Just add the phone number to your home node, it's editable by your content editors and you can access is anywhere in the site via <umbraco:Item field="obfuscatedEmail" recursive="true" runat="server"/>

    I'm not clear what you mean when you say you want in it Content as opposed to master pages? This call will work in any template anywhere on the site.

    Rich

  • philw 99 posts 434 karma points
    Apr 18, 2013 @ 16:37
    philw
    0

    Thanks... I can see how to get it into a master page (a "template"). I can't see how to get it into the content. So I want the content editor (who has no access to the master page) to be able to write text or HTML, and to simply insert the email address in obfuscated form into that content. 

    I can successfully put the address into a master page, that I can do fine. Unfortunately I want the address to appear in the narrative, in the text entered by the content editor, so it is in the wrong place. I can lift and shift it with jQuery, but I'd hoped that I may be able to insert a value such as this using the CMS. I have no problem with "templates", it's the content which is the issue.

     

    I can paste <umbraco:   tags into the content editor, but they are not parsed as such. If I type them into the HTML view, they don't seem to be rendered either (well they're parsed into some xml stuff).

    I will keep trying as I'm sure there must be a way to do this. I just want a content editor to be able to type text and then insert shared ("tokenized") values into that text, so we can maintain the content in a simple way.

    I could write a user control to do it, and then wrap that in a macro, but I'm surprised there's no easier way to insert content like this, hence I'm sure I'm missing something.

  • Rich Green 2246 posts 4008 karma points
    Apr 18, 2013 @ 16:45
    Rich Green
    0

    Ahh, I see, when you say content you mean 'Rich Text Editor' I think.

    In this case create an XSLT macro and pass the recursive paramter to it <umbraco:macro alias="RenderProperties" obEmail="[$obfuscatedEmail]" runat="server"/>

    Then output it in your XSLT with 

    <xsl:value-ofselect="/macro/

    obEmail

    "/>
    In your Macro settings check the box called 'Allow in Rich Text Editor' (or something).
    Then your users can choose, insert 'Macro' in their Rich Text Editor
    Rich
  • philw 99 posts 434 karma points
    Apr 18, 2013 @ 17:04
    philw
    0

    Thanks. "Rich Text Editor": I have the terminology straight now!

    That looks likely... I created the XSLT file (space before the word select in there, then it compiles). I created a macro and poined it at that, and ticked the box so it appears in the editor, which is what I want. 

    So now the contend editor sits in the Rich Text Editor, selects "Insert macro", then chooses the macro from the list. In my Medium Trust environment that causes this immediate YSOD:

    Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    That looks bad, perhaps this doesn't work on Medium Trust? I have other macros (for navigation) which work, although they are not available in the Rich Text Editor so they may not work there. I can prevent the YSOD by un-ticking "render in editor", so it's trying to execute the macro which is crashing with security violation.

    I tried inserting in the template:

        

    just to see if it works there, but that doesn't do anything at all.

    I think I'm missing two pieces at least:

    1. How to connect that "recursive parameter" to the XSLT.
    2. How to get the macro not to YSOD.
    Maybe there's a video of this or a step by step guide somewhere?
  • Rich Green 2246 posts 4008 karma points
    Apr 18, 2013 @ 17:47
    Rich Green
    0

    Hmm, not sure why it crashes? This is standard Umbraco stuff.

    As a test make a different macro available to the rich text editor and see if this causes a crash too?

    Rich

  • philw 99 posts 434 karma points
    Apr 19, 2013 @ 09:45
    philw
    0

    I still can't work out how to "connect" the macro with the parameter, but I tried inserting, via the editor, a built-in navigation macro, and the results are the same. I use this same macro in a Master Page File with no problems.

    This looks like a Medium Trust issue, although without knowing a lot more about Umbraco's internals I can't see what it would be doing here that it doesn't need to do to render the thing out of a Master Page, so if it's a defect then it's fixable I'm sure.  http://issues.umbraco.org/issue/U4-639 (which I commented on) is probably the cause of that. So that isn't going to work, but it should render I presume in the page itself.

    I will verify that with the standard navigation macro. If I can get that to render in the page, but not in the editor, then I should be able to do the same with this macro. Which just leaves me the issue of connecting the things together, perhaps.

    ------------------

    Server Error in '/' Application.

    Security Exception

    Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. 

    Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    Source Error: 

    [No relevant source lines]

    Source File: App_Web_insertmacro.aspx.43b758d9.mh9bs6nh.0.cs    Line: 0 

    Stack Trace: 

    [SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]

    System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0   System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +31   System.Security.CodeAccessPermission.Demand() +46
    System.Net.ServicePointManager.set_ServerCertificateValidationCallback(RemoteCertificateValidationCallback value) +57

      umbraco.macro.MacroContentByHttp(Int32 PageID, Guid PageVersion, Hashtable attributes) +932
      umbraco.presentation.tinymce3.insertMacro.renderMacro_Click(Object sender, EventArgs e) +833

    ...

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18034

  • philw 99 posts 434 karma points
    Apr 19, 2013 @ 10:13
    philw
    0

    Let me try to describe this again, as it must be blindingly simple, I just can't work it out. Hours of clicking around screens isn't helping me.

    Goal: put the telephone number (say) in one place in the site, so content editors can insert it from their "rich text editor" directly into their HTML without having to write code.

    Steps:

    0 Make it a simple hierachy
    You can only access a property within the tree that it is defined. You can't define a property at the top-level "content" node, so you have to set it on (say) a "home page" node, one level down from that. So if you have your site in separate sections, they must all be *below* that home page node, or they cannot see things defined in it. The "retrieve value recursively" looks "up the tree" only.

    So step zero is to put all the content "under" the home page, and then patch up the menuy XSLT stuff to exclude the folders or they'll appear there. In my case the "document type" alias for folders (which I do not want in a menu), is "Folder", so the code to exclude them from my menus is:

        and (name() != 'Folder') 

    Fair enough.

    1 Create the property

    1. Click "settings", then the "document type" called "home page".
    2. Click "generic properties" and then "add new property". Add a property called (say) "test" and make it a textString. Save that.
    2 Set a value for the property on the site home page.
    1. Click "content" and find the home page, click on it.
    2. Click "properties" and find the new field "test". Type the word "test" in it.
    We now have a parameter which can be accessed from any descendent of this "Home page" node. See step zero.
    3 Using the property in content
    You can't render this type of content in the wysiwyg editor as it crashes under Medium Trust. By default all macros (which you have to use to insert content) are set not to "show in editor", but to "render in editor" (a little odd as if they're not shown then how can they be rendered). No matter, reverse the sense of both check-boxes, so you can see the macro in the editor, but it doesn't render (and therefore crash).
    Remaining..
    That all works, I think. Now I just need to work out some XLST to get a value from my ancestor node. That is proving tricky.
  • philw 99 posts 434 karma points
    Apr 19, 2013 @ 20:06
    philw
    0

    Is there any way to get the XML this XSLT is working on? If I had that I could use other tools to build an XSLT and test it, then drop it in here..

  • philw 99 posts 434 karma points
    Apr 19, 2013 @ 21:01
    philw
    0

    Hmm, ok, so in a template, this:

    <umbraco:Item field="comment" recursive="true" runat="server" />
    works fine and renders the field whose alias is "comment".
    If I have some XSLT which is supposed to put the same thing in a content page by using the "rich text editor, insert macro, with a macro containing this:
       <xsl:variable name="siteRootNode" select="$currentPage/ancestor-or-self::node [@level=1]"/>
       <xsl:value-of select="$siteRootNode/data[@alias='comment']"/>
    It renders as nothing at all. I've tried it with different values of @level but that's not helping. I'm sure this has to be really really easy, I just need to pull one value from some common place. Can anyone help with this - why can't I read the value in the content (I can't have users creating Master Pages, that kind of defeats the purpose). This must be standard practice, but none of the examples seem to work :-( I'm just thrashing at random here.
Please Sign in or register to post replies

Write your reply to:

Draft