Today's plan is to make editable links. I need the links to be editable by a content editor. Links like at the top of the page Forum Projects Documentation.... I created a new document type with layout of the Master document. Then I tried to use the Related Links type in the document creator. So over in the content editor it gives me
I installed the package, but it says to create a new data type and select the multi url picker property editor, does he mean create a new document type? If so the multi url picker doesn't appear. There is some code in his readme.pdf, I don't understand where that is supposed to go.
No you need to create a new datatype based on the multi url picker. You do that in the "Developer section" under "Datatypes", where you right click the "Datatype" folder and choose the "Multi Url Picker" from the dropdown that appears. Then you can setup some configuration on this instance.
Now you can choose this multi url picker instance in the datatype/property editor drop down on your document type in the settings section.
Aaah, I totally misread the initial post. I though that the JSON data was not being updated correct for some reason...you will of course need to render the links as Jeavon says above.
I must order some stronger glasses...becoming blind it seems :D
I recreated the datatype to a relatedLinks and put in Jeavon's code. I reloaded the page and it's blank. So thinking I need to call the @umbracoField("findLink") and now I get
No I'm not literally going to do it 52 times! What I'm trying to do is set up sections, there will be 9. So each section will be for a department and they will each have their own document type and template. So each department will be able to put in a caption and link for whatever they need. I was hoping to use a foreach to go through each of their sections and display the captions on the webpage.
At the moment I have a Master template and there are unordered lists with list items. Here the caption and href links were hardcoded in. We need to change this so each department can change their own links, like here
<div class="box"><div class="car-section">
<h4>Facilities</h4>
</div>
<ul class="arrows">
<li>
<a href="/">Health & Safety</a></li>
<li>
<a href="/">Forms</a></li>
</ul>
</div>
This all has to go. So I think I'll put my foreach here looping through CurrentPage.FacilitiesDoc where FacilitiesDoc is the document type.
That's the plan at the moment, I'm sure it will change after a while!
Under the Heading Human Resources it is blank! I have a document type of alias Hrdoc and a HRDoc template. On the content tab of my HRDoc document type there is a property of type links which is a custom datatype. I ran a test page just like that and it worked. The problem is when I introduced it to the Master Page.
Ok, and in your content tree on the node that is using the HRDoc template, are you wanting to render the links from child nodes of type HRDoc on this node?
This is my Content tree, I'm not sure how to explain what I am trying to do, sorry. The links and captions from the image are what I am trying to get onto the homepage using the master template. I'm not even sure if I should be using the master template or should I be using a separate template?
The alias is hrLinks. I think the hrLinks is the grandchild of the Master. Could that be why it's not finding it? The HRDoc is of type Master and the level below, and the doc type is of type HRDoc so is the next level down. Could that be it?
Editable Links
Hi All
Happy Blue Monday!
Today's plan is to make editable links. I need the links to be editable by a content editor. Links like at the top of the page Forum Projects Documentation.... I created a new document type with layout of the Master document. Then I tried to use the Related Links type in the document creator. So over in the content editor it gives me
Then on Preview this appears
[ { "caption": "our", "link": "http://our.umbraco.com", "newWindow": false, "edit": false, "isInternal": false, "type": "external", "title": "our" } ]
instead of my link! What am I doing wrong?
Thanks.
Tony
Hi Tony
Maybe I'm blind but the link from the screendump and the data you're getting seems to be in sync to me?
/Jan
However it seems like there are a couple of issues with the picker reported
http://issues.umbraco.org/issue/U4-6139 http://issues.umbraco.org/issue/U4-6121 http://issues.umbraco.org/issue/U4-6047
So perhaps it's not functioning reliably currently so maybe the Multi Url Picker package is the better choice for now? http://our.umbraco.org/projects/backoffice-extensions/multi-url-picker
Hope this helps.
/Jan
Hi Jan
I installed the package, but it says to create a new data type and select the multi url picker property editor, does he mean create a new document type? If so the multi url picker doesn't appear. There is some code in his readme.pdf, I don't understand where that is supposed to go.
Thanks.
Tony
Hi Tony
No you need to create a new datatype based on the multi url picker. You do that in the "Developer section" under "Datatypes", where you right click the "Datatype" folder and choose the "Multi Url Picker" from the dropdown that appears. Then you can setup some configuration on this instance.
Now you can choose this multi url picker instance in the datatype/property editor drop down on your document type in the settings section.
Does this make sense? :)
/Jan
Hi Tony,
You need a little bit of Razor to render out the links.
Try this:
Taken from the documentation here
Jeavon
Aaah, I totally misread the initial post. I though that the JSON data was not being updated correct for some reason...you will of course need to render the links as Jeavon says above.
I must order some stronger glasses...becoming blind it seems :D
Nevermind me then!
/Jan
Lol, you managed to get me looking into some of those reported issues with the Related Links editor I wasn't aware of :)
Hi Jan
I created the new datatype and chose the multi url picker in the document type - Woo Hoo!
Then I copied @Jeavon's code into the template for this page and it all went south!!
I guess I put the code in the wrong place....
@Jan a friend of ours (an old man he was 78!) had trouble seeing his tv, so instead of getting glasses he got a new tv, it was 56" or 143 cm!!! :)
Thanks. :)
Tony
My code is for the Core RelatedLinks editor not MutliUrlPicker, I would go back to using RelatedLinks unless you want to pick media?
If you stick with MultiUrlPikcer then you will need this code:
Hi Tony
Well I don't think that the code Jeavon posted is usable with the multi url picker.
You need to use one of these Razor snippets to render links picked using this one, as it's also described on the package page.
Strongly Typed
Dynamic
So it's up to you if you want to use the package or just use the related links picker from Umbraco. If so then you should use the snippet from Jeavon.
@Jeavon: Ok, so it was a tad useful anyway :) @Tony: Haha, Maybe I should just zoom the page by a 1000% in my browser :D
/Jan
Oh...too slow once again. So new glasses and faster fingers I need :D
/Jan
I recreated the datatype to a relatedLinks and put in Jeavon's code. I reloaded the page and it's blank. So thinking I need to call the @umbracoField("findLink") and now I get
[ { "caption": "our", "link": "http://our.umbraco.com", "newWindow": false, "edit": false, "isInternal": false, "type": "external", "title": "our" } ]
Am I close? Maybe I need more than glasses....!!
Ah your property is called "findLink", so the code should be like this:
Jeavon I think I'm going to go to the glasses shop with Jan! If I just read the code instead of just pasting it in.....AGH!
Thanks a lot! We have hit the jackpot!!
Now I just have to do this 52 times for my 52 links!! Let the fun begin....or maybe continue!
Thanks a lot for all your help @Jan & @Jeavon :)
Tony
no no don't do it 52 times for 52 links
question one why do you have 52 links ?
question two you can make a reusable script which will take the field name as a parameter
do you want to update the script 52 times if you need to make a change?
</tuppence-worth>
Wow, you have 52 of these editors? I'm guessing you couldn't just add the 52 links into the same RelatedLinks editor?
I would certainly recommend you create a Razor helper method rather than copying this code 52 times. Do you know how to do that?
No I'm not literally going to do it 52 times! What I'm trying to do is set up sections, there will be 9. So each section will be for a department and they will each have their own document type and template. So each department will be able to put in a caption and link for whatever they need. I was hoping to use a foreach to go through each of their sections and display the captions on the webpage.
At the moment I have a Master template and there are unordered lists with list items. Here the caption and href links were hardcoded in. We need to change this so each department can change their own links, like here
<div class="box"><div class="car-section">
<h4>Facilities</h4>
</div>
<ul class="arrows">
<li>
<a href="/">Health & Safety</a></li>
<li>
<a href="/">Forms</a></li>
</ul>
</div>
This all has to go. So I think I'll put my foreach here looping through CurrentPage.FacilitiesDoc where FacilitiesDoc is the document type.
That's the plan at the moment, I'm sure it will change after a while!
Tony
Really confused now!
On the master template I have
<div class="box"><div class="car-section">
<h4>Human Resources</h4>
</div>
<ul class="arrows">
<!-- Here -->
@foreach(var page in CurrentPage.Children.Where("Visible && DocumentTypeAlias == @0 ", "Hrdoc" ))
{
if (CurrentPage.HasValue("hrLinks") && CurrentPage.hrLinks.ToString().Length > 2)
{
<ul>
@foreach (var item in CurrentPage.Hrdoc)
{
var linkUrl = (bool)item.isInternal ? Umbraco.NiceUrl(item.Value<int>("internal")) : item.link;
var linkTarget = (bool)item.newWindow ? "_blank" : null;
<li><a href="@linkUrl" target="@linkTarget">@item.caption</a></li>
}
</ul>
}
}
<!-- To Here -->
</ul>
Under the Heading Human Resources it is blank! I have a document type of alias Hrdoc and a HRDoc template. On the content tab of my HRDoc document type there is a property of type links which is a custom datatype. I ran a test page just like that and it worked. The problem is when I introduced it to the Master Page.
Anybody any ideas, I'm all out....
Thanks.
Tony
I think you need to change
CurrentPage
topage
to use the node in your foreach.e.g.
Tried that Jeavon, no joy :(
It must be close though....
Perhaps you are looking for the Children of the Home node, you would need to add
AncestorOrSelf(1)
?If not, could you post a screenshot of your tree structure and label which doc types are used on which nodes?
It didn't like that at all!!
I think this is what you mean...
The Type:Links is a datatype
I hope these image make sense! :)
Ok, and in your content tree on the node that is using the HRDoc template, are you wanting to render the links from child nodes of type HRDoc on this node?
This is my Content tree, I'm not sure how to explain what I am trying to do, sorry. The links and captions from the image are what I am trying to get onto the homepage using the master template. I'm not even sure if I should be using the master template or should I be using a separate template?
Ok, nearly there! What page are you rendering on the front end with the HRDoc template (this one or another)?
This one now and other ones as yet uncreated ones later on!
Sorry no I didnt read it right! Just this page with this doc type.
Other pages with other doc types later on. :)
Ok then, it should be this:
p.s. do you have
@RenderBody()
in your Master template?Hi Jeavon
Yes I have a @RenderBody() in my master template. Maybe that's why it doesn't like the code?
Thanks a lot.
Tony
Hi Tony,
No, you need it to be there.
Do you get an error currently or just that nothing is rendering?
Jeavon
There is nothing rendering.
Just spotted that your property alias is all lowercase.
So, try this:
The alias is hrLinks. I think the hrLinks is the grandchild of the Master. Could that be why it's not finding it? The HRDoc is of type Master and the level below, and the doc type is of type HRDoc so is the next level down. Could that be it?
is working on a reply...