I have used Sitecore field renderer for one of my page to be edited in the Sitecore page editor. That page includes an image which needs to be reference from Sitecore media library.
So I insert the image control into the markup of the Sitecore field renderer as follows
<img id="imgBusinessAdFeatues" class="classifiedImageSamples" src="~/media/Images/What is a Business Account/businessAdFeatures.ashx" alt="Business Ad with Features" />
“~/media/Images/What is a Business Account/businessAdFeatures.ashx” is the path to the image that stored in Sitecore media folder.
Now the image is rendered properly inside the page, but when I tried to edit that image (upload a new image) using Sitecore page editor it’s not allow me.
Is there any way to make the image editable (Upload a new image) when I open that page in Sitecore page editor?
Thanks
Thank you for the ideas.
But my problem is little bit different. I have Sitecore field renderer in in my sample page.
<sc:FieldRenderer ID="frTestPage" runat="server" />
From the code behind on that page, I bind a Sitecore item as follows.
frTestPage.Item = DatabaseManager.MasterDatabase.GetItem(“itemID1”);
frTestPage.FieldName = "Content";
In the item that I’m binding to the field renderer, it has richtextbox field name “Content”.
Within that “Content” field I have inserted my markup to be render to the page. So that markup consist of following img tag and other relevant HTML.
<img id="imgBusinessAdFeatues" class="classifiedImageSamples" src="~/media/Images/What is a Business Account/businessAdFeatures.ashx" alt="Business Ad with Features" />
So how can I give the image src path correctly which reference to an image in Sitecore media library.
It's wrong to use hardcoded path for images:
You can see all parameters here.
If you use XSLT to render your images, you can apply the parameters on the sc:image directly:
<sc:image field="MyImage" width="150" height="100" bc="ffffff"/>
If you use UserControls (.ascx) to render your images, you can register the following tagprefix to access sc:Image and sc:FieldRenderer:
<%# Register TagPrefix="sc" Namespace="Sitecore.Web.UI.WebControls" Assembly="Sitecore.Kernel" %>
You can use Edit(Page Editor), then More -> Insert Image, see:
Also, to have a more edit options you can use "Edit e related Item"
Related
In Kentico I'm using ASPX+Portal model created a template as a webform on disk with a single widget zone as follows:
<asp:Content id="content" runat="server" ContentPlaceHolderID="content">
<h1>Home: <%= this.PageModel.DisplayTitle %></h1>
<cms:CMSPagePlaceholder ID="plcZones" runat="server">
<LayoutTemplate>
<cms:CMSWebPartZone ID="zoneEditorContent" runat="server" ZoneTitle="Page content" WidgetZoneType="Editor" />
</LayoutTemplate>
</cms:CMSPagePlaceholder>
</asp:Content>
I then registered this in Kentico's Page templates module.
Pages using this template would now show the zone on the Page tab but wouldn't let me add widgets to it. I could browse the widget library, select a widget, set its properties, save and close the dialogue, but the page would refresh remaining empty.
After some dabbling I discovered that the relevant template record in database table [dbo].[CMS_PageTemplate] had its [PageTemplateWebParts] property set to the value '<page />'.
I discovered that changing this to '<page><webpartzone id="zoneEditorContent" v="1" widgetzonetype="editor" /></page>' resolved the problem. I could now add widgets to the zone on the Page tab.
My question is, what am I doing wrong here? I presume I'm not supposed to set this database field manually. Should Kentico be doing this automatically, and if so, what step am I missing to make this happen? I believe I've followed Kentico documentation accurately.
You are not doing anything wrong. I have to agree this is weird behavior but it is not possible (= does not take any effect) to set WidgetZoneType property in markup. You need to set it manually via admin UI (zone properties). If this is issue for you consider to add it to Kentico`s User voice.
YMHO I think you are right and it should be at least mentioned in doc that it is not possible to use this property in markup.
EDIT: My bad, please note it is mentioned in the docs, too:
Changing the WidgetZoneType property directly in layout code does not save the changes in the database. You need to set the Widget zone type property by configuring the zone properties.
As you probably already know, I'm working hard on some XPM templates with Razor. I've ran into another issue, this time concerning rendering components inside templates in order to make them siteEditable.
The following I'm not sure about. I've got a component which has a title field called "Title", and multivalue componentlink fields which consists of components with a title, description and image. Let's call this one "Linked USP" for now.
Currently this is being rendered by a Template called 'Page Banner', and it just iterates over fields with some If-loops to determine it's presentation, especially for the Title. In order for XPM to work, this template needs to render the component presentation of "Linked USP". So we've created a template called "[XPM] USP ITEM". - this Component template has the 'enable content editing TBB" added to it.
Now the issue arises when I want to make the Title Editable as well. Sounds straightforward, no? Not really - because when the parent template has got a "enable for content editing" TBB added, it will add <span> tags to all editable fields but the templates that gets invoked inside this template will also have <span> -tags, effectively bloating the html and making it impossible to edit the fields inside the RenderComponentPresentation because of duplicate <span>s.
Some code for your fun and to illustrate my issue:
<h1>#RenderComponentField("Title", 0)</h1>
#Foreach(var linkedUSP in Fields.USPS){
#RenderComponentPresentation("linkedUSP.ID", "tcm:10-1076-32")
}
This template has an enable Content edit TBB added.
now, for the RCP mentioned above, inside its [XPM] template:
<div class="title">#RenderComponentField("Title", 0)</div>
<p>#RenderComponentField("Description", 0)</p>
<tcdl:ComponentField name="img">
<img src="#img" alt="img.MetaData.alt">
</tcdl:ComponentField>
This one ALSO has the "Enable Content Edit" TBB added. On the front end this happens:
<div class="title"><span><span>Men</span></span></div>
Because the parent template also adds spans to the field.
So my question: how do i solve this? The Title field mentioned above has to be inside the parent template, but I can't create a special template for it becuase it is no component link. I can't get the TBB out of my RCP template, because it won't be editable that way. Interesting huh?
Can't I disable the spans inside template builder somehow?
Managing a "Global" Logo with Tridion
To manage, for example, a website-wide logo and its text elements with SDL Tridion, I'd want it in a component, rendered by a (dynamic) component template, and placed by page templates. My requirements would include:
Logo as a Component--image as a multimedia (mm) component and link, alt (i.e. "home"), and other text in an optional container component
Dynamic Component Presentation (DCP)--ability to manage logo's markup presentation and publish changes without requiring publishing every page
Share-able--ability to localize multimedia and text in components, rather than templates, in lower publications
Authors shouldn't need to place the logo as a component presentation (CP) on every page, although a logo CP just on the homepage could offer dynamic linking.
RenderComponentPresentation(), TCDL, or Tridion tags for "Non CPs"
For this CP-less approach, I think RenderComponentPresentation() or TCDL tag would be the right "agnostic" approach. Is one preferred over the other?
For example, my template outputs:
<h3>By tridion: (ASP.NET) tag</h3>
<tridion:ComponentPresentation runat="server"
PageURI="tcm:7-1535-64"
ComponentURI="tcm:7-1533"
TemplateURI="tcm:7-1532-32"/>
<h3>By tcdl: tag</h3>
<tcdl:ComponentPresentation
PageURI="##Page.ID##"
type="Dynamic"
ComponentURI="tcm:7-1533"
TemplateURI="tcm:7-1532-32"/>
<h3>by render component presentation</h3>
##RenderComponentPresentation('tcm:7-1533','tcm:7-1532-32')##
These get transformed to the following on the file system.
<h3>By tridion: (ASP.NET) tag</h3>
<tridion:ComponentPresentation runat="server"
PageURI="tcm:7-1535-64"
ComponentURI="tcm:7-1533"
TemplateURI="tcm:7-1532-32"/>
<h3>By tcdl: tag</h3>
<tridion:ComponentPresentation runat="server"
PageURI="tcm:7-1535-64"
ComponentURI="tcm:7-1533"
TemplateURI="tcm:7-1532-32"/>
<h3>by render component presentation</h3>
<tridion:ComponentPresentation runat="server"
PageURI="tcm:7-1535-64"
ComponentURI="tcm:7-1533"
TemplateURI="tcm:7-1532-32"/>
Each renders delivery-side so the user sees the correct CP in the browser.
Question(s):
Any approach gets us a DCP referenced from a PT with an agnostic format that gets retrieved presentation-side, avoiding full-site publishing. It's not really on the page so we have to be sure to publish the logo with a dynamic CT (it's html fragment in this case). Am I missing anything?
Is RenderComponentPresentation() preferred over TCDL or a specific presentation-side syntax? Any reason I'd actually want <tridion:ComponentPresentation runat="server"> instead?
Edit: I was missing the Type="Dynamic" attribute and value, also for a moment thought RenderComponentPresentation didn't create the right CP reference.
Basically you have answered your first question yourself already I think, apart from how you want to write it out in your template you have your DCP there.
My preference would be to use ##RenderComponentPresentation('tcm:7-1533','tcm:7-1532-32')## but I would actually not use it with hardcoded TCMURIs. I'd probabaly write a TBB which reads the Multimedia Component TCMURI and its Template URI somewhere from for instance a configuration Component or the Publication metadata, then your template could look something like:
##RenderComponentPresentation(${LogoUri}, ${LogoTemplateUri})##
When using Dreamwever TBBs for your layout, I would use this as a preference. If you are using another way of layout, then the next best thing would be to use the TCDL tag. Indeed to try and keep your templates code agnostic. The only time I would ever revert to writing out the tridion control code myself, is when I cannot get it there another way.
I want to create a custom content block in Sitefinity so I can wrap an tag around it and pick up my CSS.
I created a custom widget, but I'm not sure how to make it a content block. I cannot find documentation on this, but I'm sure it is a common occurrence. Basically, I want a drag out content block that does this:
<aside>
[code for content block]
</aside>
I don't know how to generate the [content block] code in .net. I am new to .net development. I am using VB but can use C#.
Any help would be greatly appreciated. Thank you.
Maria
You can create a custom Layout Control which can be used in conjunction with other controls, such as Content Blocks.
To create a Layout control, open your project in Visual Studio and create a new control (.ascx) file in the WebApp project. I normally put mine in a ~/LayoutControls folder which I create. In that control file, enter something like:
<div runat="server" class="sf_cols">
<aside>
<div id="Div1" runat="server" class="sf_colsIn"></div>
</aside>
</div>
You'll notice that besides the markup you want, the aside tag, I have two other divs with some specifics. These are needed so Sitefinity can treat this as a control, and be able to dynamically inject content into it.
A div with class sf_cols is common to all controls and the div with class sf_colsIn (id="Div1") is where control you drop onto the layout control will go. So there is an outer wrapper div, your markup, and an inner div. It's the inner div where your content will go.
Save your file, compile the project, then register the control in Sitefinity.
To do that, login to the backend then navigate to Administration | Settings | Advanced Settings | Toolboxes | Toolboxes | PageLayouts | Sections. I normally add a new section with these properties:
name=Custom,Title=Custom,Description=Custom Layouts,Global resourceClassId=PageResources
Then select your new section, select Tools, then Create New. The Name, Title, Description are whatever makes sense for you control. The Control CLR Type should be Telerik.Sitefinity.Web.UI.LayoutControl, Telerik.Sitefinity and the Layout Template should be the path to your ascx file, i.e. ~/LayoutControls/AsideBlock.ascx. The other properties can have the default values (most are just blank). Then Save.
Now when you are editing a page, click the 'Layout' button in the right hand column and you will see a 'Custom' Section which contains your control. Drag it onto the page, then go back to 'Content' editing (using the button in the right hand column). You will see your layout control and drop a content block onto it.
Add content normally. When the page renders, the content will be wrapped in the aside tag.
the easiest way to do this is with an external template for the content block. The template you want is ContentBlock.ascx and is in the SDK.
Copy this file to your project then add the wrapping tags around the contentHtml literal control (which renders the actual content of the control).
Then open the Advanced settings of the content block widget you want to use this template and specifiy the LayoutTemplatePath. It should have a default value of something like "~/SFRes/Telerik.Sitefinity.Resources.Templates.Backend.GenericContent.ContentBlock.ascx".
Simply change this to the virtual path to the template you created, then save and publish the page.
The content block will render with your template instead of the default one, with any markup you add.
I hope this is helpful!
I'm going to create a more detailed blog post that walks through this process and will link it here when I'm done. thank you for the inspiration!
I am creating a new plone.app.theming (Diazo) theme for my site. My rules.xml has the rule:
<theme href="theme.html" css:if-content="#visual-portal-wrapper" />
This unstyles many popups, but not the contact-info AJAX popup box, which is empty. I can unstyle it using the following rule:
<notheme css:if-content="body.template-contact-info"/>
but this means that any user visiting that page, and not rendering it in a popup, will see it unstyled.
How can I successfully unstyle the contact-info popup box?
The login form popup is wrapped inside a <div class="pb-ajax">. Just look at the generated HTML that creates the popup and you will find a class or identifier that you can use to select that particular popup.
On the other hand you can also customize the Plone view that creates this piece of HTML. Though it will be much easier to try to get a class or identifier.