How can you attach a content item as an element field of another content item via its authoring template? - websphere-portal

Let's say I defined a IBM WCM authoring template called "AT-Image"; it creates content item "CT-Image" that contains elements such as an Image of type "Image", Description of type "Short Text", Keywords of type "Text", and other fields that serve as meta for that image resource.
Now, I need to create a content item called "CT-Article" based off from its "AT-Article" authoring template. Let's say that "Article" item has 3 elements: Title, Summary, and Image. Title and Summary are of type "Short Text". But Image needs to be of type "CT-Image" and not Image or Image component.
Is this possible Out-of-the-Box or is this something I need to implement myself via WCM API?

From my point of view you should use a menu component in the following way:
Let's assume you have got your CT-Image and CT-Article in a common sitearea called "MyArticle" like this:
MyArticle
CT-Article
CT-Image
Furthermore you need a WCM Menu component which uses two selection criteria:
current sitearea as location
CT-Image as authoring template
So then rendering CT-Article with a presentation template PT-Article you can reference the menu component. Therefore, you reference the menu component in the presentation template markup. The menu component then will pick up the CT-Image and render it as it is located in the same sitearea as your CT-Article.
That's rather a content design approach then a technical approach. It's all there out-of-the-box and saves custom development effort.

If I understand correctly, basically you want to create pre-defined images and then pick one of them to display when you create an article. Correct?
Well, the easiest way would be to utilize what WCM already gives you: create an Image Component. You will be able to upload the image and also provide a description, but you won't be able to set keywords or metadata. The workaround for this would be to set the keywords/metadata as part of the article. If that is okay, this would probably be the best way to do it.
By doing that, all you would have to do is select the relevant Image Component from your Image Element in AT-Article.
If you really need the images to be their own content items (rather than components) so that they have their own keywords and other information, then the next "easiest" way is probably to use an HTML Element inside AT-Article. In this HTML Element you will have to use the "Insert Tag" option, and then choose an Element Tag and use "Selected" rather than "autofill" or "current" to navigate to the content item that you want (the one with the image).
The code will look like this:
[Element name="[path]" type="content" context="selected" key="[element]"]
Where [path] is the path to the content item and [element] is the element that you actually want to pull from that content item (such as image, description, keywords, etc.)
context="selected" is the key there. Then you just need to set up your Presentation Template to be able to use this information that you are pulling in from the HTML Element.

WCM 8.5 has the InContext tag.
The InContext tag renders a tag body within a specified context. The new context can be specified as a predefined context by using a UUID, or by path.
For eg. in this case you can use below where key="Image" in InContext tag is the Link element to the CT-Image content item :
[InContext uuid="[Element context='current' type='content' key='Image' format='id']"]
[Element context="current" type="auto" key="Image"]
[Element context="current" type="auto" key="Description"]
[/InContext]

Related

Displaying custom html in form.io grid view (dynamic CSS class)

I'm trying to set up a form.IO form that will let me use the value of a field as part of the css class. This needs to take effect when the item is in the table view. If it also influences the form view that's ok because we don't have the element showing in the form view.
Specifically I want to get the following output:
<div class="[value]Stoplight"> </div>
The values from the object are going to be colors e.g. "yellow" so the result would be:
<div class="yellowStoplight"> </div>
Once I have that I can have my CSS file specify a background image based on the class and make it display the way I want.
Alternatively if I could put an html element of type image and have the source be different based on the value of the object that would work too.
Any ideas on how I could make either of those work? I'm not finding anything that relates to "dynamic css". Perhaps I'm looking for the wrong search criteria.

Constrict user to fill just one of several properties

We have a block type in our EpiServer project that can have either specify a video to use (an EPiServer.Url) or a youtube id (string). The thing is that it only makes sense to use either of those, not both. Is there a way of marking one field readonly if the other is filled?
Not using vanilla editors, I'm afraid. But you could fairly easily create a custom editor (dojo widget) for that use case.
Here's an example of a custom editor to display a checkbox list for selecting blocks, instead of the standard editor for ContentArea properties:
https://tedgustaf.com/blog/2016/create-a-custom-editor-for-a-content-area-in-episerver/
However, the same principles apply for any content type.
To be clear: you don't need a custom property type, just a custom editor. The backing property type could still be string, which would contain either the URL or the YouTube ID.
If you want the property to be more developer-friendly, you could create a block type with "YouTube ID" and "URL" properties, and then define a content property of that block type.
You would then use your custom editor to set either the "YouTube ID" or "URL" property of that "VideoBlock" property.
We have created a similar editor before, where the editor would either select a video using a dropdown, or specify a custom video stream URL.

Custom Theme template in Drupal 7

I know, if you want to check the names of the Display Output of the view page then we need to click on the Information Link near by Theme of Advance Theme of the view, it will list all the files.
After clicking on this, it will list.
Display Output : (View Machine name is add_to_cart)
views-view.tpl.php, views-view--add-to-cart.tpl.php, views-view--default.tpl.php, views-view--default.tpl.php, views-view--page.tpl.php, views-view--add-to-cart--page.tpl.php
So, could you please suggest which files should be best for creation of the Display Output template of the view page ?
If you want specific theming to your page display of add_to_cart view, then choose
to override views-view--add-to-cart--page.tpl.php.
I'll also want to add the importance of naming convention for templates, so that, next time, you can choose the template name yourself:
views-view.tpl.php: called for every view.
views-view--add-to-cart.tpl.php: called for only add_to_cart view.
views-view--default.tpl.php: called for the display: default(master display) of every view.
views-view--page.tpl.php: called for the display: page of every view.
views-view--add-to-cart--page.tpl.php: called for the display: page of only add_to_cart view. (the specific suggestions are always last)
Note:
Template naming suggestion flow: general to specific.
Also when you click the display output, you can copy the code for the template. This way you get all the variables that are available to you.
Hope this help else comment for queries.
Understanding how default, page comes in template names:
Within a view, you can create many displays as shown below.
Each display has a Machine Name, for eg: System display has a machine name: system_1. So, a view with system_1 display will be overrided using views-view--system-1.tpl.php. Note: the underscore('_') is replaced with hyphen('-'). The by default view display or master display in a view has a machine name: default.

Drupal 7 - how can I control content layout in a view?

I've been handed a design spec which requires a news listing in a specific format - e.g. image floating to the left, with the main title and content on its right.
I've created the articles listing using the views module and embedded the view as a block on the front page. However, I need to change the layout of the resulting list of items at an html level, as the items are not provided in the order or within the html tags that I need in order to deliver the design.
In order to style the output, I really need the views module to give me fine-grained control over the html tags being wrapped around each field for each article.
Is this possible in Drupal?
(edit: please note, this is not a css question - I know how to float and position things in css. I need to be able to modify the html tags applied to fields in a view - thanks!)
When you go to your view, you will see FORMAT. You can change the Format to HTML list with corresponding settings. Under Show, you will say Fields. In the FIELDS area, choose which content you want enabled. Let me know if this helps, or if you want more of an explanation. Go back into your view and click on your field. The next window that pops up should be to configure that field. You'll see style settings where you can define the HTML tags, classes, wrappers, etc.

Extjs add grid panel to accordion content

I'm actually not sure if this is possible, but I will ask it anyway. I have a group of accordion controls, and within the content body of each I need to display a grid panel. The grid panel needs to have a click event attached to it. I have tried simply creating the grid panel and setting the html property of the accordion to it, but this produces no content.
Is there somehow I can achieve the above?
You cannot have html content (inserted by the property) along with any other content. If you add any item the html property value will not set/overriden. But for sure you can place anything you want into one accordion panel. Even a grid. But for that case, and based on the last question, I would recommend you to reference the view into the grid. You may do this simply by using a ComponentQuery
The click events can be applied by using the control function of the controller.
For your basic understanding:
In ExtJS you seldom use plain html code. In most scenarios you use any sort of component. All is nested within the items-array or dockedItem-array. Items within these arrays get also processed by the layout system.
Some Query examples applicable to the control function
In the following this refers to the controller itself.
You know the Id of the grid (normally you didn't do this). Id's are marke by a starting #
control({'#yourId': {itemclick: this.onItemclick }});
You know the xtype and that there is only one instance of this type. You can also describe a path by using spaces between the xtypes.
control({'grid': {itemclick: this.onItemclick }});
You have set a custom property to grid (you can refer any property this way). This one is fully compatible the the one above. I recommend this one in your case
control({'grid[customIdent=accordionGrid]': {itemclick: this.onItemclick }});
This are just some ways to use ComponentQueries, there are more. For a more detailed explanation you should refer the sencha API for ComponentQuery
Also note that every component implements the up() and down() methods which also support ComponentQueries.
I forgot to mention: For a control the query strictly need to return just one result (only the first one will be taken) a ComponentQuery on the other hand can return multiple results.
This is perfectly possible but the accordion's body is not the place to put that in. You'll need to add it to the items: [] array of the accodion. The body (or html) only accepts html.
Example:
http://docs.sencha.com/ext-js/4-1/#!/example/layout/accordion.html
this one has a grid within it.

Resources