RenderFields Pipeline does not show all Fields in Sitecore - sitecore

So i was trying to add title tag for all my images in Sitecore.
John West had a solution here
The issue is, I am not getting all the rendering fields in my pipeline. When i debug the Solution, the breakpoints hits only 4 or 5 times totally and they are all different fields either under footer. Interestingly all of them are only "Rich text" Fields. What am i missing? Why am i not getting all the fields under Sitecore.Pipelines.Renderfield.RenderFieldArgs?
I am also using Glassmapper and using #RenderImage to render the images. Couldthat be the reason?

GlasMapper does not run through the RenderField pipeline in Normal mode (it does in edit mode), this issue has been raised before as an issue on Github for String field types.
You can either force it through the pipeline by creating a custom html helper extension which works in much the same way as Glass does in Edit mode.
Or alternatively I'd suggest creating a custom Glass Mapper Data Handler inheriting from SitecoreFieldImageMapper and then overriding the MapToImage methods. Use that as the type for your property or replacing out/insert before the existing mapper registrations in DataMapperConfigFactory.

Related

Sitecore Glass Mapper - Using Item Renderings

I'm setting up a carousel in Sitecore using Glass Mapper. In the foreach loop to generate each carousel item, I can get the items out easily enough and make them editable with the #Editable command. What this doesn't give, however, is finer control over the edit process. For example, I want to edit the background image using a custom button in the Experience Editor, but I need to set that up in a rendering.
If I was using straight Sitecore, it looks like I'd use Html.Sitecore().ItemRendering and pass in the carousel item as a regular Sitecore item. In this case, I have my strongly-type class from Glass Mapper, which can't be passed in that way.
Is there a comparable method in Glass Mapper for setting up an item rendering? Or is there another way to affect the Experience Editor buttons for the carousel items? I've also experimented with setting up a separate edit mode, which would work fine, but I wanted to put together a cleaner editing experience with a more WYSIWYG approach to the item.
You'll have to use Custom User Experience Buttons which will allow you to edit in Page Editor Mode.
I just googled and found couple of good article which might help you.
http://www.nishtechinc.com/Blog/2015/March/A%20Better%20Approach%20at%20Carousel%20Management
http://www.awareweb.com/awareblog/11-25-14-custombuttonspageeditor
Try Html.Glass().BeginEditFrame() functionality built into Glass Mapper, wrapped in a #using block.
It allows you to specify the fields you wish to edit directly as params. Or if you're feeling adventurous, it can point to a full edit frame configuration in the core DB.

Glass: Property of Template not Populated

Sitecore 8.0U5, Glass 4, TDS 5.0.1.11
I've got an interesting problem here and I feel like I'm just being dense somewhere, but can't figure it out.
I've got a template in Sitecore called "Testimonial" that has text fields like "Quote", "Name", "Location". It additionally has a field named "Image" of type "Image".
TDS generates my code and the properties of the template look normal. When viewing the rendering, all the fields are mapped appropriately except for the "Image" field. It is always "NULL".
The image is displayed in my view rendering only when viewing in the Experience Editor. When I 'Preview' or browse to the page, the image does not display. To complicate things, when I put a breakpoint on the rendering line and inspect in either Experience Editor or Preview, "Image" is still NULL. So even though it doesn't appear to be mapped, it still works in the Experience Editor.
I'm running locally and have my site pointed to the master database.
Anyone seen anything like this or have any ideas for additional ways to troubleshoot?
Thanks!
Okay, this is not an issue with Glass. (Not directly, at least) The issue is that there is a third-party module that has a template named Image and when that was mapped by TDS, it was interfering with Sitecore's Image class.
I'm not sure if this was the best solution, but what I ended up doing was editing the T4 template to look for this specific template and update the name when the class is generated. This keeps the module template named appropriately and keeps the compiled code clean as well.

Sitecore Conditional Showing of Fields

So I am rather new to sitecore, and it's a topic that wasn't covered during my training. My questions is just to help point me to the correct term, or documentation on a method to do the following.
I have a definition item, with a ton of field groups, what I want to do is something like:
if Value of Field X is "yes" then collapse/hide Field X or Field Group X.
Does that make sense? Is it a validation rule? or some other kind of rules, is it a workflow I need to attach? Do you place it on just the field I want to hide, or the field that triggers the action?
I appreciate any guidance.
There is nothing out-of-the-box in Sitecore to achieve what you want but there is no reason you cannot create a composite custom field type to do this. The following articles will help you achieve this:
Creating a custom Sitecore Field
Getting to Know Sitecore: Custom Fields, Part 1
Create a new control, inheriting either from Droplist (if the comparison of the value is to be text based) or Droplink (for comparison of ID). You could add a parameter in the Source field of the control to specify what the values that trigger the hide should be.
The underlying control in the Content Editor is just a standard HTML select element. Add onchange events to the control and add your Javascript handler to hide the other controls. Since I could not find a way of adding additional custom css classes to the Sitecore controls, it would be best/easiest to hide all other controls in the same collapsible group after you control. This would mean you would need to group your controls better (or logically at least).
The Javascript will be something like this (the Content Editor uses the Prototype JS framework):
if ($(this).getValue() == 'no') {
// find the parent container of this control and then hide all the next siblings in the same group
$(this).up('.scEditorFieldMarker').nextSiblings('.scEditorFieldMarker').invoke('hide');
}
You can test this by running the above in the console, change out the keyword this with the id of your field, e.g. $('FIELD2292054').
What I am not sure about is how to trigger the hide on initial load, i.e. when someone returns to an existing item, it may be possible by adding to one of the pipelines, but would be better using a JS solution if possible. I'll have a think about this and get a proper code sample up over the next few days.
EDIT: You can add an event handler to sc:contenteditorupdated to handle the content editor being rel-oaded.
document.observe("sc:contenteditorupdated", myFunction);
I wrote up a blog post and put the code on GitHub if you are interested.
Not sure if you have come across Andy Uzick's this blog post.
He wisely talks about hiding fields in the Content Editor and has also created a Sitecore Module called Hide Field Template Extension which is hosted on the Sitecore Marketplace with the full source code to extend.
After reading through and trying the extension, I do feel that it will not completely resolve your issue (how you have described it in the question).
But it will give you:
A mid-term solution to hide a few unnecessary field that some content editors would not like to view.
Fields that are only required by administrators for admin purpose - to de-clutter these fields could be hidden.
Just one thing to bear in mind that it mentions in the requirements Sitecore 6.5 & 6.6. I have not tested it in Sitecore 7. If you are using Sitecore 7, which I think you are, one could modify the source code and make it work for Sitecore 7.
Have a look and share your findings.
Happy Sitecoring!

Sitecore Page Editor issue

I was trying to move components in Page Editor mode , and below are the things I have done to achieve this :
Set Compatible rendering selected for the Sublayouts
Added placeholder settings and allowed controls for placeholders
But , when I was trying to move components, the DataSourceItems for the sublayouts are not changing , hence the content is not changing.
And , also sometime I am getting Field related errors if the fields are different in the DataSources.
Can someone please help me in this .
From your question, it sounds like you are trying to move a component from one placeholder to another in Page Editor. That does not affect the data source.
If instead you mean you are trying to personalize the experience by using rules to switch the data source within a sublayout, the steps you've taken won't allow for that. You need to add conditions to the sublayout in Page Editor to choose which data source you want to display.
If you are trying to have compatible renderings (different sublayouts) show for the same placeholder, that is something that is done by your step 1. This is only to help authors know what other sublayouts would be a good idea to put in that placeholder. It does not affect the data source.
When you add components, the datasource for them is not set automatically. You need to check if it's set and use Sitecore.Context.Item if it's not.
Not sure if that's what you mean..
As for field related errors, please post more details.

custom sitecore shell tools for en masse workflow approval

I'm wondering about documentation to create a simple custom ribbon control for sitecore shell.
The problem i'm trying to address is that Admins should be able to force all subitems recursively to be approved to a certain workflow state (rather than approve each one manually), but we currently don't know any way to achieve that.
To solve this, we want to force items throught the workflow state (triggering the corresponding commands) programmatically, but we need a sane way for admins to interact with this, the sensible option would be a custom thingie in sitecore shell, but we aren't sure how easy is to achieve that.
any recommended readings for this problem?
Though this article claims to be written for Sitecore 5.3, the same steps apply for 6.x as well. Note: it requires access to the SDN: How to create a ribbon button in Sitecore v5.3
The high-level points from the article are:
Create a new class that inherits from Sitecore.Shell.Framework.Commands.Command
Mark the class as [Serializable]. It might not be necessary for simple commands, but add it now so you don't get problems later! Otherwise the button might not work correctly (this is related to pipelines - and the fact that pipelines might be stopped and resumed)
Override Execute() and possibly also GetIcon(), GetHeader(), QueryState(), GetClick(), GetSubmenuItems()
Add a new <command name="…" type="..."> tag to /App_Config/Commands.config file
Log into Sitecore and switch to the core database
Navigate to /sitecore/content/Applications/Content Editor/Ribbons and create (or copy) a command in the desired chunk
Enter your command name (the one from step 4) in the "Click" field (and supply a Header, Icon, Tooltip, etc)