How to access cck fields in tpl file? - drupal-6

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.

Related

Customize search results and facets in Liferay 7.1

this is my first question, thanks in advance.
I am trying to customize the liferay results portlet and facets, with custom results. I need to filter the results once the search is launched, and remove the results that do not have layoutId :
with->
layoutIds = journalContentSearchLocalService.getLayoutIds(groupId,false,articleIdResult);
I´m doing this in a jsp fragment, but i think that it´s not correct.
I have been searching and i think the correct way is to modify the java class with the action, for example with acction coomand hook, is this correct?
Please, can you explain me the correct way to modify this functionalities?
Regards!!
ok. it looks you want result of journalarticle having display page is set. in that case, you need to look for JournalarticleModelPreFiltercontributor component extension or journalarticlepostprocessor if you are using legacy search api. when article gets indexed layoutuuid field is also indexed for each article. that field will have value if display page is set for specific web content or article.
So, you can use any of the above mentioned way to add check that this field should not be empty as search term. which will filter your result in request itself. instead adding overhead on result as later filtering in jsp.

how to set value in orchard core text field in asp net core

I'm trying to write my own API to fill an orchard core content type which has several text field. for example the content type named "test" has two fields named first name and last name and are text fields.
I know by using contentItem.Content.test.firstName.Text.Value I can get the value. but as I use contentItem.Content.test.firstName="Mary" and then calling createAsync, just a new content Item is created which is empty.
would you please help me?
thanks
ps:test is the part name too
I solved the problem by using dynamic object variable

MediaLibraryPickerField : how to pick only provided Content types?

MediaLibraryPickerField has a seeting named "DisplayedContentTypes". I think it is used to provide only required content types that I want my picker field to select and render. But somehow it is not working.
E.g: I want to select only Image,OEmbed types. I put it in the settings area's text box:
Content Types and Parts
[Image,OEmbed]
A comma separated value of all the content types or content parts to
display.
and saved it. But it is still picking all kind of media and rendering them.
Any thing I might be missing here??
There is an open issue here https://orchard.codeplex.com/workitem/21051
There is no fix yet although.
Indeed, the property exists but is not used.
We should try to implement a filter, as it is done for the content picker field.

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

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