Get root taxonomy name in drupal view - drupal-6

I'm using Drupal 6 and have a view with a field having the taxonomy name.
But I want to get the root taxonomy name. How can I have this?
Thanks in advance.

Ok, I haven't found a way to do this purely through the Views administration, but you could create a template file for a Views field to do this. It sounds like you want to replace the term name with the root name...
If you could make that field have the taxonomy term id (tid) instead of the name, you can create a template for the field (determine the name for the tpl file under Basic Settings->Theme) and add this code:
<?php
$term_parents = taxonomy_get_parents_all($output);
print $term_parents[count($term_parents) - 1]->name;
?>
This will replace the term id and instead will display the root term name in its place.
If you are stuck on using the name, you could always throw a database query in there to convert the name to the term id to use with the template code.

Related

How to get one of repeatable text field liferay7 Freemarker

I created a Web content Dsiplay ( Text as a repeatable field in structure ).
In the structure template i wanted to have only the third element.
I tried
${Text.getSiblings()[3].getData()}
But it doesn't work
I am using Liferay-7 and Freemarker as Stucture template
Thank you
Index fields start with 0 so the solution for the 3rd element is :
${Text.getSiblings()[2].getData()}

Orchard CMS: Content Item Get Field By Name in View

I have created a custom content type (via the admin UI) that consists mostly of text fields. I know how to position the fields using zones and Placement.info but for simplicity I would like to use a single view template and to just arrange the fields by name instead of having to use Placement.info. Is there a good way to reference the fields by name from the content item in my MVC view?
So for example, I have a template named Content-MyContentType-Detail.cshtml. Instead of the generic
#Display(Model.Content)
I would like to be able to do something like
#Display(...MyField...)
#Display(...MyOtherField...)
Is there a way to explicitly render a field by name that is associated with my content item?
You can use Shape Tracing module to view model properties and how to get access to content parts.
Then in your template you can use something like this:
<h3>#Model.ContentItem.TitlePart.Title - £#Model.ContentItem.Product.Fields[1].Value</h3>
<p>#Model.ContentItem.BodyPart.Text</p>
If you don't just want to access the field's properties, but rather would like its shape rendered in-place, but like it would be when using placement (i.e. using the existing template), then read this article, which describes how to do direct rendering without placement: http://weblogs.asp.net/bleroy/archive/2013/02/13/easy-content-templates-for-orchard-take-2.aspx

Sitecore how to check does sitecore content tree item available for extranet/anomouse user

Hello is is possible to define grammatically does extranet/anonym user has access to content tree item ?
I need it like additional case in my IHttpModule.
Thanks.
You can use AuthorizationManager class to get any access right information like this:
Sitecore.Security.AccessControl.AuthorizationManager.IsAllowed(
item,
Sitecore.Security.AccessControl.AccessRight.ItemRead,
User.FromName("domain\\name", AccountType.User)
);

How to access cck fields in tpl file?

I am working on one already created drupal site. In themes folder it has one tpl.php file, Where theme is done to display the content. Now it is as follows
print $content
And all the fields of cck are displayed properly. But I want to access every field like Title, Body etc. I have tried with $content['title'], But nothing is displayed.
Can anyone please tell me how to access different fields in my tpl file. I am using Drupal 6.
Thanks in advance.
try to
<pre>
print_r($content);
</pre>
then you will see what's exactly in the array.
You can use node-[type].tpl.php to see the different fields. There, by default, each CCK field is exposed in a variable named with the field's name, for example if you have a field called field_logo then you have a variable called $field_logo which is an array representing the field's processed values and can be print_r()'d.
More template suggestions are available in Drupal documentation. And more information on using node.tpl.php and its derivatives is available too.

How to create a lookup column that targets a Doc Lib and uses the 'Name' of the document?

How do you create a lookup column to a Document Library that uses the 'Name' of the document as the lookup value?
I found a blog post that recommends adding another custom field like "FileName" and then using a item reciever to populate the custom field with the value from the Name field but that seems cheesy.
Link to the blog in case people are interested:
http://blogs.msdn.com/pranab/archive/2008/01/08/sharepoint-2007-moss-wss-issue-with-lookup-column-to-doc-lib-name-field.aspx
I've got a bunch of custom document content types that I dont want to clutter with a work around that should really work anyway.
I created a one step workflow to set the title from the name, fired on modify and created. Seems to work and took seconds to create.
One way you can do this (although not the easiest way) is by creating a custom field type that extends the SPFieldLookup class. SharePoint's field editor for Lookup fields purposefully hides any columns types that aren't supported by Lookup fields, but you can create a field editor for your custom field type that shows them.
However, I have created a Lookup column that points to a Name column in a Document Library before, and it probably doesn't work like you'd expect. While the value stored in the lookup column is valid, it doesn't show up right in List view or on the View Properties form.
The solution you posted may actually be the best way to handle this. Lookup fields require some kludges if you want to handle more complex scenarios, but that's because they're not meant to provide the same functionality as a foreign key relationship in a database.
Coding in any form always scares me. So Here's what I did: I simply renamed the Stupid "Title" Field to something else, say "Keywords", since you cant do anything with that field: cant even make it mandatory.
Then I created another Single line field called "Title" and used this field for the Lookups
Well there is a simple solution to that and in might work in some case.
In the nutshell if you make the Title field Mandatory, this will force the user to enter a title. In that manner we can use title field as a lookup field.
Now How to do that?
One you are done create a document library go to the library setting. Select Advance Setting and Select Yes for the option "Allow management of content types?".
Then go back to the Library setting and Under content types select the "Document" Content type. THen Select Title Column and then Select "Required (Must contain information)" and say OK.
Now try uploading a document to this document library. You will see Title field in the form.
Hope this helps
Cheers
Vaqar
You have to add the field as XML with the ShowField as 'FileLeafRef'
var XmlFieldDefinition = "<Field DisplayName='myLookupColumn' Type='LookupMulti' StaticName='myLookupColumn' Name='myLookupColumn' Required='FALSE' List='THE LOOKUP ID HERE' WebId='THE WEB ID HERE' UnlimitedLengthInDocumentLibrary='TRUE' Mult='TRUE' Sortable='FALSE' ShowField='FileLeafRef' />"
Field fld = fieldCollection.AddFieldAsXml(XmlFieldDefinition, true, AddFieldOptions.DefaultValue);
ClientContext.Load(fld);
ClientContext.ExecuteQuery();

Resources