Keyword

Listing based on extra field

  • Zebra Film
  • Zebra Film's Avatar Topic Author
  • Offline
  • New Member
More
11 years 9 months ago #108225 by Zebra Film
Listing based on extra field was created by Zebra Film
Looking for a way to create a listing of one extra fields that links to the full item.
We use for example extra field ID 10 for a special title and just want to show this list of titles.

I have found many listing modules but none of them just does this.
It seems so simple that I am even thinking about looking at the example plugin :-)

We want to display it in the body but of course a module in loadposition will also do the trick.

Suggestions welcome.

Bastiaan

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

More
11 years 9 months ago #108226 by BBC
Replied by BBC on topic Re: Listing based on extra field
Can you give few examples at live sites ?

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

  • Zebra Film
  • Zebra Film's Avatar Topic Author
  • Offline
  • New Member
More
11 years 9 months ago #108227 by Zebra Film
Replied by Zebra Film on topic Re: Listing based on extra field
Not sure if it is of any use but here you go:

marleensboekvandeweek.nl

We have book reviews and use the extra fields for a lot of additional fields, like subtitle , but alos the block below has been redone with custom fileds following this: jurawa.com/notes/item/27-update-2-making-k2-more-like-a-true-cck-custom-admin-templates-and-calling-specific-extra-field-data

My client wanted to use the title for the teaser so I had to make a subtitle extra field showing the booktitle.
Now she wants to list the booktitles....

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

More
11 years 9 months ago #108228 by BBC
Replied by BBC on topic Re: Listing based on extra field
It is New Year man, and i made a test specially for you.

Put K2 content module where you want your display, strip in iz everything except "extra fileds" and in your template override (template/yourtemplate/html/mod_k2_content/yourcustomtemplate/default.php change

<span class="moduleItemExtraFieldsValue"><?php echo $extraField->value; ?></span>

to

<a class="moduleItemExtraFieldsValue" href="<?php echo $item->link; ?>"><?php echo $extraField->value; ?></a>

It will style all your extra fileds that way but you get picture how to use forum and echo just one extra filed and set it as link to Item.

If you want to use template override and Css4K2 it is up to you. If you chose to link just one extra filed then you can change default.php in K2 folder. But you will get it as link in every K2 content module. Suit yourself best.

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

  • Zebra Film
  • Zebra Film's Avatar Topic Author
  • Offline
  • New Member
More
11 years 9 months ago #108229 by Zebra Film
Replied by Zebra Film on topic Re: Listing based on extra field
yes Happy New Year!

Thanks for helping out, appreciated!

Good idea to use a content module with override and subtemplate for experiments.

Issues:
I need to display only 1 specific extrafield , not all.

On the site I use this code:
<!-- Call to prepare extra fields -->
<?php
//convertArray to use ids as key
$extrafields = array();
foreach($this->item->extra_fields as $item)
{
$extrafields[$item->id] = $item->value;
}
?>

and then

<?php echo $extrafields[10];?>

to show the titel.

When I create a 'naked' content module with only extra fields (still with original code) I get them all.
Not sure I can somehow filter it out by ID or that I need to use the code above to get back to the right field.

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

  • Zebra Film
  • Zebra Film's Avatar Topic Author
  • Offline
  • New Member
More
11 years 9 months ago #108230 by Zebra Film
Replied by Zebra Film on topic Re: Listing based on extra field
I have found that you can call an extra field by alias, not sure this also works in a module:

$this->item->extraFields->EXTRAFIELDALIASHERE->value

I am not good enough in PHP to understand where and how I could use this to generate the a listing.

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

More
11 years 9 months ago - 11 years 9 months ago #108231 by BBC
Replied by BBC on topic Re: Listing based on extra field
Dont know if module is prepared for this in its PHP files, as category and item.
I am just trying to make it works with simple menu link to K2 categories. But i have that damn problem that Css4K2 is not working OK in Joomla 3.

I cannot force my setting in menu link for custom K2 template, and simply cannot test anything.
Css4K2 give advantage to K2 category template setting, not Menu K2 link setting, in simple word it is not working.

I know it is easy and possible.
- Chose Menu link
- Chose several (or one) categories.
- Disable aspolutely everything from view.
- In your custom K2 template category_item.php disable options for K2 to check for settings for extra fields, if they are activated for view in category listing, or not.
- And put your code for custom /specific) extra field.

This line is important, disable checking in K2 category parameters.

<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>

There is not point i test it on my old Joomla instlation because you use latest 2.6.2 K2 version. And latest modules, codes.

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

More
11 years 9 months ago - 11 years 9 months ago #108232 by BBC
Replied by BBC on topic Re: Listing based on extra field
Btw problems like this are reason why i long ago started to learn Drupal. And i regret i didnt do this earlier.

Joomla community have precis started to catch with Wordpress (yes, they are years ahead of Joomla), not mention Drupal. With philosophy like this maybe they will be as Drupal for 15 years, if they dont end as Mambo.

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

  • Zebra Film
  • Zebra Film's Avatar Topic Author
  • Offline
  • New Member
More
11 years 9 months ago #108233 by Zebra Film
Replied by Zebra Film on topic Re: Listing based on extra field
OK got it working with some workarounds:

Needed to have more than one category to be able to choose a subtemplate
Used the extrafield alias in category-items and did some CSS to get it look better.

Thanks for the suggestions! (and agree it is a pain, compared to standard Joomla or Drupal)

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

More
11 years 9 months ago - 11 years 9 months ago #108234 by BBC
Replied by BBC on topic Re: Listing based on extra field
Can you please put your tweak code here ? I cannot make it work unless K2 Category has enabled view of extra fields in Category layout. It it some solution you sometime dont want at whole page.

I meant more Joomla as platform, not K2. If Joomla was more as Drupal it would not be difficult to show specific field wherever you want. Like it is now every extension, module and plugin are macrocosmos for itself.

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


Powered by Kunena Forum