As a Razor newb I'm using the 'foreach (node / item in...' quite often.
But when I have multiple TABS inside one node (all with a different name, like 'sub 1', 'sub 2' etc), how do I loop through all these UI tabs? Those tabs all share the same fields ('page title', 'content', etc).
How about the following (although bear in mind that this is potentially slow as is using the Document API which will hit the database).
using umbraco.cms.businesslogic;
using umbraco.cms.businesslogic.web;
Document document = new Document(123);
foreach (ContentType.TabI tab in document.ContentType.getVirtualTabs)
{
}
Instead, can you identify which tab a property is on based on it's alias ?
Thanks for your reply! Erm.... can you explain why this would be slow? And in which way? I mean, would my whole website become slow because of this, or just the section which includes this code?
I'm just suprised there isn't a simple solution for this, is this a such strange question? So nobody ever uses the same content in multiple tabs and uses a loop to go through all tabs?
Can you explain in more depth what you're trying to do ? It's not clear from your other post if you want to duplicate the properties from one tab to the other, or the values of properties from one tab to the other - perhaps there's another way ?
Haha sure, I'm sorry for the unclear explainations. Here's what I'm trying to achieve:
I am creating a website, existing of one long page. Divided into multiple sections to define the 'subpages' ('Home', 'About us' etc) by using different background colors. It's all about vertically scrolling.
In one section, however, I'm introducing horizontal scrolling as well. To give you a simple example: you know the App Store from Apple, right? When you are on your iPhone and selecting a game (for example), you can scroll down reading all properties and rankings of this game. But there are also screen shots from the game. You see only the first one of them, and have to scroll HORIZONTALLY to view the others. This idea is what my questions are all about.
So, to come back at my website: the section 'Portfolio' shows an overview of all services the company can deliver. For example websites, prints, etc. I created a grid of 3 x 3 images with a title beneath every one. So the first one is a link to 'websites', the next to 'prints' etc. When you CLICK on one of the images (links), the page scrolls to the left automatically, and thus replaces the current section ('overview') by the requested section ('websites'). In the websites section, there's the same 3 x 3 grid, which enables the admin to post 9 images of created websites for the portfolio. But how should I build all of this in Umbraco?!?
There we go: First of all - I'm a big fan of usability. So I don't want to make the users need to create subnodes under 'Portfolio' since I believe the left part of the UI is just for PAGES, not for SECTIONS ;-) So I created multiple tabs under 'Portfolio' ('sub1', 'sub2') and used 'uComponents' to convert them into real subpages (buttons) under the main tab 'Content'. Each subpage has the same fields 'Pagetitle', 'Foreword' and 9 images (upload). So at this point, when I'm creating these 11 properties for all subpages, I have to rebuild them for EVERY tab instead of being able to copy them and just add a valid prefix. I also hoped that even this prefix was unnecessary, because all properties are on a different tab. This clearly doesn't seem to be an option - so I'm forced to use a prefix after all.
But what's with the copying restrictions? Why can't I grab my three properties ('Pagetitle', 'Foreword' and 9 images) and copy them over the other 8 subpages?
I hope this extensive explaination makes it all a bit clearer now.
It's nice to hear your using SubTabs ? and I know what you mean about wanting to avoid nodes in the left hand tree that are not pages - do you have a specific number of sections that always appear within a portfolio page ?
If it's variable, then I'd suggest using child nodes (or another datatype like MultiDataType, EmbeddedContent or DataTypeGrid) so that you don't have to define an arbitary number of items, this would also simplify sorting, and the property names can remain consistant, hence the rendering loop would also be simplier. (Incidently, if your site is a single url, I don't imagine you have a single node in the content tree ?).
If however using sub tabs makes more sense, it's probably not worth progmatically creating each group of properties, as it's a one off manual task.
Indeed, the maximum number of sections will be 9 (since the 3 x 3 grid on the overview section can only show so many sections). SubTabs works great, and I am already using Embedded Content. Unfortunately, Embedded Content doesn't work with RTE, which is just what I need. So I manually have to add this RTE for each subtab.
I see that you are trying to find a work around for me - for which I'm grateful! - but this also shows me Umbraco hasn't got a way to copy properties from one tab to another in the DocType.... :-(
In the meanwhile I have found a work around for myself, but thanks anyway!
I'm starting with building all Razor code now, so you can expect me back soon! ;-)
Foreach 'tabs'
As a Razor newb I'm using the 'foreach (node / item in...' quite often.
But when I have multiple TABS inside one node (all with a different name, like 'sub 1', 'sub 2' etc), how do I loop through all these UI tabs? Those tabs all share the same fields ('page title', 'content', etc).
Hi Peter,
How about the following (although bear in mind that this is potentially slow as is using the Document API which will hit the database).
Instead, can you identify which tab a property is on based on it's alias ?
HTH,
Hendy
Hi Hendy,
Thanks for your reply! Erm.... can you explain why this would be slow? And in which way?
I mean, would my whole website become slow because of this, or just the section which includes this code?
I'm just suprised there isn't a simple solution for this, is this a such strange question? So nobody ever uses the same content in multiple tabs and uses a loop to go through all tabs?
Thanks for helping Hendy, I'll give it a try! ;-)
p
Ooow now I see: you can't just create properties with the same name under different tabs of one page: you have to give em all a different name!
But.... why is this? Why can't the unique part of a property be the tab which it is on (tab 1, tab 2)?
Hi Peter,
Can you explain in more depth what you're trying to do ? It's not clear from your other post if you want to duplicate the properties from one tab to the other, or the values of properties from one tab to the other - perhaps there's another way ?
Cheers,
Hendy
How about prefixing your property alias with something to indicate the tab to which it belongs ?
Hi Hendy,
Haha sure, I'm sorry for the unclear explainations.
Here's what I'm trying to achieve:
I am creating a website, existing of one long page. Divided into multiple sections to define the 'subpages' ('Home', 'About us' etc) by using different background colors. It's all about vertically scrolling.
In one section, however, I'm introducing horizontal scrolling as well. To give you a simple example: you know the App Store from Apple, right? When you are on your iPhone and selecting a game (for example), you can scroll down reading all properties and rankings of this game. But there are also screen shots from the game. You see only the first one of them, and have to scroll HORIZONTALLY to view the others. This idea is what my questions are all about.
So, to come back at my website: the section 'Portfolio' shows an overview of all services the company can deliver. For example websites, prints, etc. I created a grid of 3 x 3 images with a title beneath every one. So the first one is a link to 'websites', the next to 'prints' etc. When you CLICK on one of the images (links), the page scrolls to the left automatically, and thus replaces the current section ('overview') by the requested section ('websites'). In the websites section, there's the same 3 x 3 grid, which enables the admin to post 9 images of created websites for the portfolio. But how should I build all of this in Umbraco?!?
There we go:
First of all - I'm a big fan of usability. So I don't want to make the users need to create subnodes under 'Portfolio' since I believe the left part of the UI is just for PAGES, not for SECTIONS ;-)
So I created multiple tabs under 'Portfolio' ('sub1', 'sub2') and used 'uComponents' to convert them into real subpages (buttons) under the main tab 'Content'.
Each subpage has the same fields 'Pagetitle', 'Foreword' and 9 images (upload). So at this point, when I'm creating these 11 properties for all subpages, I have to rebuild them for EVERY tab instead of being able to copy them and just add a valid prefix. I also hoped that even this prefix was unnecessary, because all properties are on a different tab. This clearly doesn't seem to be an option - so I'm forced to use a prefix after all.
But what's with the copying restrictions? Why can't I grab my three properties ('Pagetitle', 'Foreword' and 9 images) and copy them over the other 8 subpages?
I hope this extensive explaination makes it all a bit clearer now.
Thanks again.
Hi Peter,
It's nice to hear your using SubTabs ? and I know what you mean about wanting to avoid nodes in the left hand tree that are not pages - do you have a specific number of sections that always appear within a portfolio page ?
If it's variable, then I'd suggest using child nodes (or another datatype like MultiDataType, EmbeddedContent or DataTypeGrid) so that you don't have to define an arbitary number of items, this would also simplify sorting, and the property names can remain consistant, hence the rendering loop would also be simplier. (Incidently, if your site is a single url, I don't imagine you have a single node in the content tree ?).
If however using sub tabs makes more sense, it's probably not worth progmatically creating each group of properties, as it's a one off manual task.
Just my 2 cents,
HTH,
Hendy
Hi Hendy,
Indeed, the maximum number of sections will be 9 (since the 3 x 3 grid on the overview section can only show so many sections). SubTabs works great, and I am already using Embedded Content. Unfortunately, Embedded Content doesn't work with RTE, which is just what I need. So I manually have to add this RTE for each subtab.
I see that you are trying to find a work around for me - for which I'm grateful! - but this also shows me Umbraco hasn't got a way to copy properties from one tab to another in the DocType.... :-(
In the meanwhile I have found a work around for myself, but thanks anyway!
I'm starting with building all Razor code now, so you can expect me back soon! ;-)
Thanks again!
is working on a reply...