Copied to clipboard

Flag this post as spam?

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


  • Keon Dadgostar 6 posts 76 karma points
    Feb 11, 2020 @ 15:49
    Keon Dadgostar
    0

    I've created a quiz on the website quiz-maker.com and I want to embed it onto my web page using the text editor. However, when I paste in the embed code using the source code option, it doesn't seem to load. Is this because it involves using script tags? Please could someone help me to embed this? I should probably also point out I am very new to Umbraco!

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Feb 11, 2020 @ 15:54
    Steve Morgan
    0

    Hi,

    You'd be best changing this field to a text area and ensure that you output the text in the View template with

    @Html.Raw(Model.YourPropertyAlias)
    

    The html raw tells razor not to encode your html and script tags.

  • Keon Dadgostar 6 posts 76 karma points
    Feb 11, 2020 @ 16:25
    Keon Dadgostar
    0

    I'm sorry I don't completely understand what I need to do. I have the embed code in the text area on my content page. And then the @Html.Raw(Model.YourPropertyAlias) goes in the View template? I can't seem to locate where that is. Sorry if I'm being dumb here.

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Feb 11, 2020 @ 19:20
    Steve Morgan
    0

    Hi,

    it sounds like you're using a rich text editor - not a text area.

    Are you an editor with an Umbraco site or are you doing the development with it?

    Rich Text editors tend to mess with markup that you paste in and will likely filter the script tags. If you can, I would use a separate text area instead to add this embed code.

    Then you need to go and edit the template (view) to output this new text area with the razor code I gave you above.

    Does that make more sense? Do you have access to the Settings / Developer sections in Umbraco?

    Steve

  • Keon Dadgostar 6 posts 76 karma points
    Feb 11, 2020 @ 21:42
    Keon Dadgostar
    0

    Hi

    I am editing from the back end of an Umbraco site, not on a rich text editor.

    I've added in the code into its own text area, using a text widget.

    I do have access to the Settings/ Developer sections, but I don't know my way around it very well, so I'm not sure where that razor code should go. I placed it in the Standard Page template (Views/StandardPage.cshtml) and all I got was runtime errors so I took it out again!

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Feb 12, 2020 @ 09:27
    Steve Morgan
    0

    Can you post a screen shot of the text widget?

    If you have a view source button that is most likely the rich text editor in Umbraco but let's see.

  • Keon Dadgostar 6 posts 76 karma points
    Feb 12, 2020 @ 09:40
    Keon Dadgostar
    0

    enter image description here

    Let me know if you need me to see anything else.

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Feb 12, 2020 @ 11:04
    Steve Morgan
    0

    Hi,

    Yes - that is the rich text editor - the field "Text" is using a Rich Text Editor. In Umbraco you can add extra fields.

    I would recommend you add a new field to this document type

    Go to Info tab and you'll see Document Type on the right - click the open link.

    You'll see your document type and will be able to add properties. Let's add one to the Widgets tab. Give it a name "Embed Code" and choose the Editor (click Reuse and find TextArea). Save this - this won't do anything until we add it to your template.

    So go back to your Lookup page and then back on the info tab see what template is being used (same deal - click Open).

    Then find where your Text field is being output.. and give me another screenshot so we can write the bit of Razor for you.

    If you're feeling brave you can try pasting this below the Text.

    @(Html.Raw(Model.Content.GetPropertyValue<string>("embedCode")))
    

    Then if nothing is broken go and add your quiz code to this new field. Steve

  • Keon Dadgostar 6 posts 76 karma points
    Feb 12, 2020 @ 11:22
    Keon Dadgostar
    0

    enter image description here

    I've opened the template that's being used, which has led me to here. I better not risk doing it myself!

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Feb 12, 2020 @ 11:26
    Steve Morgan
    0

    Hi,

    Before you do anything copy the contents and save them to a text file somewhere local.

    But if you add a return after the closing brace } on line 22 and add that line I gave you it should work.

    Probably worth pointing out here that if you have developers that work on your site you'll need to let them know about this change as if they release something it will likely over write this.

    I'm assuming you don't have them though?

  • Keon Dadgostar 6 posts 76 karma points
    Feb 12, 2020 @ 11:54
    Keon Dadgostar
    0

    It works!!

    Thank you so much for your help and patience! You're a star!

    I'll let the digital team know I've added this in.

    Thanks again!

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Feb 12, 2020 @ 13:47
    Steve Morgan
    0

    Glad to help - send my apologies to the digital team.

    They might not like this change - I probably should have asked if you had one!

    Steve

Please Sign in or register to post replies

Write your reply to:

Draft