I have some templates for AzureDevops Feature item type that have some predefined fields (e.g. AreaPath, IterationPath) and as a title, I would like to use the Parent item title with a prefix, e.g. [prefix] Parent item title.
Is there any way to reference the parent item title in the template field definition? I was thinking (and tried, with no success) something like:
Title = [prefix] #ParentTitle
Title = [prefix] #Parent.Title
Title = [prefix] $ParentTitle
Title = [prefix] $Parent.Title
Giving that a template could be applied to an existing item, I am also curious if I could at least access the current Feature title through the template in a similar way, maybe like:
Title = [prefix] #Title
Title = [prefix] $Title
I basically want to not add a generic Placeholder title, but instead use either the parent item title or the current item title with some adjustments.
Related
I'm a complete Modx newbie and I'm trying to update an existing website. My goal is to add a new category to some pages as shown in the table below:
Checkout the documentation for this here https://bobsguides.com/creating-a-new-category.html
To create a new Category
Click on the Elements tab in the tree at the left in the Manager
Right-click on the "Categories" folder in the Element tree
Select "New Category"
Enter a Name for your new Category
(Optional) Enter a parent Category if you want to have Categories within Categories
It seems your question about MIGX TV functionality, this is how you should solve this:
Update your MIGX TV with the next category field (in Form tabs):
{"field":"category", "caption":"category", "inputTVtype":"listbox",
"inputOptionValues":"#EVAL return $modx->runSnippet('getCategoryList');"}
Create snippet getCategoryList with next code inside:
<?php
$result = array();
$c = $modx->newQuery('modCategory');
$c->sortby('category','ASC');
$categories = $modx->getCollection('modCategory',$c);
foreach($categories as $category){
$result[] = $category->get('category')."==".$category->get('category');
}
return implode("||", $result);
I have an array with different properties. The title property will be duplicated but the other properties in that item will not. I need to display the title property in a table however only if they are not duplicates.
my code below
data-bind="id: 'criteria_category_item_' + Criteria_Category_ID, text: Criteria_Title"
the above will display text for all titles even if they already exist so i now have duplicates in my table.
How would i do this in a foreach ?
there is no data-bind="id
you probably look for attr-binding:
data-bind="attr:{id: ...},text: ..."
I have problem to insert content item to Content type. In Orchard administration I created custom content type with fields: name, surname, date etc...
But inserting new content items I must do in controller method programmatically. I tried this, buth this no work:
var item = this._services.ContentManager.New("Zadosti");
item.Name.Value = "Some dummy usage of this product"; // I can not access name field
this._services.ContentManager.Create(item);
You probably attached the fields directly to the custom "Zadosti" content type?
What Orchard in that case does is attaching the fields to a part named exactly the same as the type, it doesnt ever attach the fields to the content type itself (dont let the dashboard fool you!)
Therefore you can access the field as following:
var item = this._services.ContentManager.New("Zadosti");
// 'Zadosti' in here is the name of your part, which is
// the same as your content type name
item.Zadosti.Name.Value = "Some dummy usage of this product";
this._services.ContentManager.Create(item);
Since I never worked with Orchard CMS I have a SEO related question.. is it possible to have title of a page/ article like: title of a page/article | title of website | website url? Because what I have now is backwards order.. Tnx in advance
In your theme you need to overwrite Document.cshtml
The original can be found here:
~/Core/Shapes/Views/Document.cshtml
The title is added to the page using:
#{
var title = Convert.ToString(Model.Title);
var siteName = Convert.ToString(WorkContext.CurrentSite.SiteName);
var baseUrl = Convert.ToString(WorkContext.CurrentSite.BaseUrl);
}
#Html.Title(baseUrl, siteName, title)
You can add as many parameters in the Title helper method as you want and they will be shown separated by the separator specified in site settings. They are displayed in reverse order.
So:
<title>#Html.Title("Item 1", "Item 2", "Item 3")</title>
will be rendered in HTML as:
<title>Item 3 - Item 2 - Item 1</title>
I am working on an Orchard site that needs to be able to use some customized forms to create new content items.
To handle this I'm using a controller to display a form and then trying to create the new content items on post back by populating the dynamic items and then sending them through the ContentManagerService's Create() function.
This is working ok until I got to the content picker field I have as part of my content item.
In my project I have a content type of Question Record that has a SubmittedBy field that is a Content Picker Field.
Here is what I can see in the immediate window while processing the post back:
> dynamic q = _questionService.NewQuestion("Why doesn't this work?");
{Custom.Website.Models.Question}
base {Orchard.ContentManagement.ContentPart}: {Custom.Website.Models.Question}
IsNew: true
OriginalQuestion: "Why doesn't this work?"
Summary: null
> q.QuestionRecord
{Orchard.ContentManagement.ContentPart}
base {System.Dynamic.DynamicObject}: {Orchard.ContentManagement.ContentPart}
ContentItem: {Orchard.ContentManagement.ContentItem}
Fields: Count = 5
Id: 0
PartDefinition: {Orchard.ContentManagement.MetaData.Models.ContentPartDefinition}
Settings: Count = 0
TypeDefinition: {Orchard.ContentManagement.MetaData.Models.ContentTypeDefinition}
TypePartDefinition: {Orchard.ContentManagement.MetaData.Models.ContentTypePartDefinition}
Zones: {Orchard.UI.ZoneCollection}
> q.QuestionRecord.SubmittedBy
{Orchard.ContentPicker.Fields.ContentPickerField}
base {Orchard.ContentManagement.ContentField}: {Orchard.ContentPicker.Fields.ContentPickerField}
ContentItems: null
Ids: {int[0]}
The ContentItems property is read-only and the Ids when assigning a new int[] to the Ids array I get a System.ObjectDisposedException with the message: Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.
Are there any workarounds to get this value set in code or do I need to create my own property to store the related content item ids? It would be very helpful to have the admin interface of the ContentPickerField also available.
Thanks.
If you have a reference to the ContentPickerField, you can assign it a value using the Ids property.
In example (assuming your content type has a part called Question which has a field called SubmittedBy):
var submittedByField = ((dynamic)q.ContentItem).Question.SubmittedBy;
sbmittedByField.Ids = new[] { submittedById };
As Bertrand mentioned, the format to access a content field is: contentItem.PartName.FieldName.
If you attached a field to a type directly via the admin, the part name has the same name as the type name, hence contentItem.TypeName.FieldName (where TypeName is actually the name of the implicitly created part).