Hi all,
I want to hide some sections in the Blog Post in the Dynamics 365 Portal. But there is no Webpage corresponding to it. Can anyone help how and where can I insert the code ? I'm attaching the pic of the section I want to hide ?
Hi all,
I want to hide some sections in the Blog Post in the Dynamics 365 Portal. But there is no Webpage corresponding to it. Can anyone help how and where can I insert the code ? I'm attaching the pic of the section I want to hide ?
Hi Kirat,
It seems that there is no Web Page record for us to edit Blog post page.
Making change to theme.css may not work because the section element hasn't a specific id or class name attribute.
So a solution would be that we could add a custom javascript on a global scope element: Header.
var path = location.pathname; if (path.indexOf("blogs") > -1 || path.indexOf("news") > -1) { document.getElementsByClassName("content-panel")[0].style.display = "none"; }
Because URL of blog page starts with "blogs",
and blog post's starts with: "news/{title}"
location.pathname will search pathname of web site, then we could search in the value whether any thing matches specific name.
Our function will execute when page is loaded.(window.onload event)
Result:
When open blog post page with console for debugging, we can see that due to current path contains "news", so code in brackets will execute to hide specific section.
Regards,
Clofly
Thankyou so much for your quick response and your solution worked like a charm for the Blogs.
The only issue I'm facing now is that whenever a new Blog is created it has associated Blog posts with it, and these sections would pop up on the Blog Posts even if we hide it on the Blog. Would you recommend making changes to the theme.css to make it happen for the Blog Posts or is there any other effective way?
In addition, you can also hide it with pure css rule:
div .content-panel:nth-child(2) { display: none; }
Please notice that if we hide element by javascript, the start index is 0,
if css, the value starts from 1.
Regards,
Clofly
Hi Kirat,
Please follow steps below to hide a specific section.
1. In blog web page, open console and find correct index number of section which you would like to hide:
e.g: hide "Options", its index equals 1:
2. In Web Page > Information form of blog page, double click record in Localized Content.
3. It looks like we are still in same record, but actually the form has been changed to "Content"; open Advanced tab to add custom javascript code.
It will hide section element which its index equals 1.(I added an alert to test whether it would work.)
$('.content-panel').eq(1).hide();
4. Save the modified record, and if update not works, click "Browser website" button in PowerApps portal editor to refresh cache.
5. Then when we open blog page again, it will firstly show alert.
after I close alert, the section will be hidden.
Regards,
Clofly
André Arnaud de Cal... 291,711 Super User 2024 Season 2
Martin Dráb 230,458 Most Valuable Professional
nmaenpaa 101,156