ASPX templates
Version 7.x > ASPX templates > You Tube Output for loops within loops View modes: 
User avatar
Member
Member
dave-watts-the-solution.co - 7/22/2013 11:40:18 AM
   
You Tube Output for loops within loops
Hi guys,

Just finished developing a site with Kentico - very custom build, where I've used the tree structure in order to build complex user controlled content - so for example, the site contains a page which the user can add several content "stages" to - each one can be configured to display the information for that stage differently.

The easiest way to do this was to have foreach loops within loops and if statements etc.

The issue is that the final piece of the puzzle is allowing the user to output a "youtube" stage. I'm taking the content from the Rich Text Editor and outputting it in the HTML and getting this:
^youtubevideo|(width)560|(height)347|(rel)False|(url)http://www.youtube.com/watch?v=xxxxxxxxxx|(fs)True|(loop)False|(autoplay)False^

I've found that this method http://devnet.kentico.com/Blogs/Martin-Hejtmanek/December-2010/How-to-Resolving-the-inline-controls.aspx i.e. placing the content into a literal inside a placeholder and passing that control through a function.

However, as the code is in loop within a loop it's non-trivial if not impossible to dynamically create the controls and try to do this with each one. It also seems slightly insane.

So the question is, is there another way to get to the functionality contained in CMS.ExtendedControls.ControlsHelper.ResolveDynamicControls and pass in the node rather a control.

Any help would be much appreciated, thanks

User avatar
Member
Member
Swainy - 7/24/2013 4:22:11 AM
   
RE:You Tube Output for loops within loops
Hi Dave,

I had this exact problem and unfortunately I couldn't find a way of doing this without using the literal approach. I'm hoping this will alter in version 8.0 and we will be given a way of doing it in code. I got the following response fom Support:

'I have discussed your issue with our development department and regrettably this is not supported scenario in Kentico. The dynamic controls are transformed to special objects on pre-render according to their type.

Alternatively, you can develop your own in-line controls to store the embed HTML code directly to the database instead of control macros.'

Thanks,

Matt

User avatar
Kentico Support
Kentico Support
kentico_janh - 7/26/2013 4:31:09 AM
   
RE:You Tube Output for loops within loops
Hello,

You can take advantage of our controls like a repeater, which resolves dynamic controls automatically through the transformation as we solved it by e-mail.

Best regards,
Jan Hermann

User avatar
Member
Member
megawatts - 8/20/2013 2:00:35 AM
   
RE:You Tube Output for loops within loops
Hi, just wanted to follow this up with a last comment for people searching these boards trying to solve an issue like this.

I'd like to start by saying Jan was very patient, polite and as helpful as he could be - in short the support was excellent and speedy, the following complaint is aimed at the software only.

In the end this had to be abandoned - we had to deliver something slightly substandard to the client where they used the Rich Text Editor to place the full youtube embed iframe into the HTML - as opposed to the nice friendly functionality built into the CMS.

What Jan is saying is technically correct - the issue can be solved by using a repeater inside a repeater and using the OnItemDataBound event to hook up the internal loop.

However, the reason we had to abandon this was:
1) This is a horrendous way to have to build websites. Kentico's recompile time is awful so the last thing you want to have to do is to be tweaking changes inside the ascx page, recompiling and waiting a couple of minutes for the result each time. Anyone who has integrated complex modern HTML pages into any CMS would agree with this - the way you use the template language is the primary way you achieve efficiency in integrating the HTML cut.
2) Using repeaters in this way results in very unreadable / untransparent code where you have to start referencing the code behind to have any idea of what's going on - the very last thing you want inside a template!! This is the absolute opposite of the use of the simple inline for loops I wanted to use.
3) Repeaters are limited - no code forks
4) With reference to 3) the suggestion was to use things like
<%# Eval("aBoolValue") ? "some html" : "some other html" %>

With the complex HTML we were trying to output, while this would work it would leave more unreadable code which is very hard to debug / change in the future

There is a reason I went for using as much normal inline c# as possible on the aspx pages - no 5 minute re-compile times for small tweaks and clean readable HTML - both on the ASPX pages and the resulting HTML.

So I would argue that the issue wasn't "solved" - an unrealistic suggestion was put forwards instead.

My suggestion to the dev team would be to extract the functionality which processes things like the youtube tags to enable this processing to happen outside of a specific control - I see no reason to limit the ability to call this functionality to just that method of calling it.