I was hopeful that I could just update the render partial of the embed editor for the grid:
\AppPlugins\Grid\Editors\Render\embedvideowrapper.cshtml
But this is only wrapping the iframe with a div and at best this only does half of what I'm looking for - as I want to apply CSS classes directly to the iframe as well.
Does anyone have any thoughts on the best approach to modifying this partial? Or another entry point to modify.
I have do this thing yesterday. You can edit the embed.cshtml file in /views/Partials/Grid/Editors/ and insert a div with a class around the @Html.Raw(Model.value):
Then I have create a new css file "customgrid.css" and load this file dynamically with javascript. For dynamically loading I have added this code in the /views/Partials/Grid/Editors/Base.cshtml:
<script type="text/javascript">
function loadCSS(filename) {
var file = document.createElement("link")
file.setAttribute("rel", "stylesheet")
file.setAttribute("type", "text/css")
file.setAttribute("href", filename)
if (typeof file !== "undefined")
document.getElementsByTagName("head")[0].appendChild(file)
}
var styles = document.styleSheets;
var cssExist = false;
if (styles.length != 0) {
for (var i = 0; i < styles.length; i++) {
if (styles[i].href != null && styles[i].href.match("/css/customgrid.css")) {
if (styles[i].cssRules != null && styles[i].cssRules.length == 0) {
// request for css file failed, make modification
break;
} else {
cssExist = true;
}
}
}
if(cssExist==false)
{
loadCSS("/css/customgrid.css");
}
} else {
loadCSS("/css/customgrid.css");
}
</script>
Maybe there is not the best solution, but it should work.
Maybe you must only add the customgrid.css in your template and not in the base.cshtml. Try it out. In my case I have a lot of other styles in the customgrid.css for changing the default style of grid editor in backend.
Umbraco Grid editor, YouTube, and Bootstrap
Hi,
I would like to render links to YouTube videos in a way that bootstrap v3 likes: http://getbootstrap.com/components/#responsive-embed
I was hopeful that I could just update the render partial of the embed editor for the grid: \AppPlugins\Grid\Editors\Render\embedvideowrapper.cshtml
But this is only wrapping the iframe with a div and at best this only does half of what I'm looking for - as I want to apply CSS classes directly to the iframe as well.
Does anyone have any thoughts on the best approach to modifying this partial? Or another entry point to modify.
Thanks Chris
Hi Chris,
Perhaps you could use the package called responsive youtube macro for grid to solve your needs. https://our.umbraco.org/projects/website-utilities/responsive-youtube-macro-for-grid
Hope this helps,
/Dennis
Hi Dennis
Thanks for the pointer. I used Michael's YouTube package and change partial to suit my Bootstrap v3 needs.
Here is the code for the partial should any follow in my footsteps:
Note: I've added URL parameters to hide the related videos and video title. The parameters are defined here:
https://developers.google.com/youtube/player_parameters
im trying to do the same as above, but:
Any pointers how to do this in 7.2.6?
Hi,
I have do this thing yesterday. You can edit the embed.cshtml file in /views/Partials/Grid/Editors/ and insert a div with a class around the @Html.Raw(Model.value):
Then I have create a new css file "customgrid.css" and load this file dynamically with javascript. For dynamically loading I have added this code in the /views/Partials/Grid/Editors/Base.cshtml:
Maybe there is not the best solution, but it should work.
Hope this helps?
Best, Sören
I was too fast....
Here is the customgrid.css:
Maybe you must only add the customgrid.css in your template and not in the base.cshtml. Try it out. In my case I have a lot of other styles in the customgrid.css for changing the default style of grid editor in backend.
Best, Sören
is working on a reply...