YOOtheme Pro is here! The best WordPress and Joomla theme. Learn more

Avatar sebas.nannings asked

Add date field to List Widget

I want to create a widget List module with date + titel.
But it can only show the Title. What cab i do to show the date as wel?

I prefer above the title or in line with the title (date | title).

Why adding the mapping feature when you can't add these fields to the widget?

  • ZOO
  • Widgetkit
  • Eat

2 Answers

0

Avatar thomas.p Support answered

Hi sebas.nannings,

the widgetkit is showing settings for all widgets. However, some widget views don't include all attributes. By doing some customization you can add the date as follows.

Mind that this change will be overridden by any widgetkit update.

Widget Settings

Apply the following mapping in your widget content:

  • map content: name
  • map date: creation date (or publish date or ...)

Image

Select show: content in your widget settings->content:

Image

Code changes

Access your site via FTP and edit the list widget view file at administrator/components/com_widgetkit/plugins/widgets/list/views/widget.php with an UTF8-capable editor as follows:

after line 80-82

$title = '<h3 class="uk-margin-remove">' . $title . '</h3>';  
                break;  
        }

add the following lines

// Meta  
        if ($item['date']) {  
            $date = '<time datetime="'.$item['date'].'">'.$app['date']->format($item['date']).'</time>';  
            $meta = $app['translator']->trans('Written on %date%',  array('%date%' => $date));  
        }

after the line 103 (now line 109)

<?php echo $title; ?>

add the line

<?php echo $date; ?>

Result

Image

Now this is simply adding the date right after the title. To add some spacing or change the styling you would need to adapt the code to your needs, of course.

Kind regards
Thomas

Please mark this question as accepted if the answer helped you. More about it here: Mark as accepted
Image

Edited

0

Avatar snowpoloi answered

nice solution if i have to enter the created date from k2???
now is the published date...i want to use it for events

Know someone who can answer? Share a link to this question via email or twitter.