Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Needs update: Cms.Context needs documentation and mapping / Template editor snippets are out of date #2560

Closed
ajplopez opened this issue Oct 18, 2021 · 2 comments

Comments

@ajplopez
Copy link
Sponsor

I'm submitting a ...
[x] bug report

...about
[x] Razor templating

Current behavior

I have an app that uses the OpenGraph code. It looks like this:

HtmlPage.Title = @Dnn.Portal.PortalName + " > " + @Content.Title;

HtmlPage.AddOpenGraph("site_name", @Dnn.Portal.PortalName); 
HtmlPage.AddOpenGraph("title", @Content.Title); 
HtmlPage.AddOpenGraph("type", "website");
HtmlPage.AddOpenGraph("url", @Dnn.Tab.FullUrl + "/resource/" + Content.Link);
HtmlPage.AddOpenGraph("Description", @Content.Description);

But in the newer 2sxc with CmsContext, these @Dnn.Tab.Whatever don't work anymore. I try using @CmsContext.Site.PortalName but there isn't a clear mapping from the old ones to the new ones.

I found that HtmlPage.AddOpenGraph("site_name", @CmsContext.Page.Url); works as expected but very few others that I'm trying to convert work.

When I use the Snippets in the sidebar, it's still adding old code like Dnn.Tab.Url which is outdated.

Expected behavior

The snippets needs to be updated so we know how to get those values.

Instructions to Reproduce the Problem
Use the new 2sxc 12.5 and try to use the snippets to display the DNN Site Portal Name.

Why change the behavior?

Out of date / I don't know how to get these things via Razor anymore.

Your environment

  • 2sxc version(s): 12.50
  • Browser: [all ]
  • DNN: [all ]
  • Language: [any/all ]

Anything you would like to add

@iJungleboy
Copy link
Contributor

We'll try to do that asp.

BTW: the old behavior will still work of course if you use an old base-class for the razor files.

If you use newer base classes then you can always use @inherits Custom.Dnn.Razor12 in which case the Dnn object will still be available. In that case you can use the new IPageService and still use the @Dnn... variables.

@ajplopez
Copy link
Sponsor Author

@iJungleboy Ahh, that makes sense. Since originally posting, I realized afterwards that I did have the old things working in other templates and was so confused. Appreciate the help, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants