Keyword

Creating extra fields

  • nibelungen
  • nibelungen's Avatar Topic Author
  • Offline
  • New Member
More
11 years 11 months ago - 11 years 11 months ago #105893 by nibelungen
Creating extra fields was created by nibelungen
Hello,

I'd like to create some extra field for k2 categories and use the value for the category view. I've been able to display the extra field but I can't seem to get the parameter from the xml file.

I have added those two lines in administrator/components/com_k2/models/category.xml
<param name="extra_class" type="text" size="10" default="" label="K2_EXTRA_CLASS" description="K2_EXTRA_CLASS_DESC"/>

...

 <field name="extra_class" type="text" size="10" default="" label="K2_EXTRA_CLASS" description="K2_EXTRA_CLASS_DESC"/>

And I have this line in templates\ja_vintas\html\com_k2\ja_vintas\category.php
 <!-- Subcategory title -->
<h2 class="<?php echo $this->params->get('extra_class'); ?>">

I can see the extra field I put in admin panel and enter a value and save it. But that extra_class value is always empty. How can I make it work?

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago #105894 by jeandenis
Replied by jeandenis on topic Re: Creating extra fields
Hi,

Why do you want this class for ? If it has to be different each time, just add another text field and display it in your markup as a class.

If you need more flexibility with custom fields, don't miss this tutorial :
getk2.org/documentation/tips-a-tricks/item/221-custom-admin-templates-and-calling-specific-extra-field-data

Please Log in or Create an account to join the conversation.

  • nibelungen
  • nibelungen's Avatar Topic Author
  • Offline
  • New Member
More
11 years 11 months ago #105895 by nibelungen
Replied by nibelungen on topic Re: Creating extra fields
Hi

I have a multilingual website. And I need to have certain titles or elements to have a specific class in order to solve the issue of text:uppercase styling. I'm using the class information in my javascript file to make it work.

Well, your solution might do the trick. I will look into it. Thank you.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum