Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[com_tags] Menu List of items that have been tagged with the selected tags can not display variables about $this->item->event->beforeDisplayContent; #18992

Closed
shionphan opened this issue Dec 6, 2017 · 17 comments

Comments

@shionphan
Copy link

shionphan commented Dec 6, 2017

Steps to reproduce the issue

  1. Creat any tags and assign tags to a article.
  2. Creat Fields for this article in Articles manager. (Content - Articles - Fields)
  3. Creat a menu which is 'List of items that have been tagged with the selected tags.'
  4. Set Item Description as show in menu opition List Layouts
  5. Visit this page which creating by step 3.
  6. It dose not display any Fileds.

Expected result

  1. Open file: /components/com_tags/views/tag/tmpl/default_items.php
  2. Go to line 98, see code <?php echo $item->event->beforeDisplayContent; ?>
@joomla-cms-bot joomla-cms-bot changed the title Menu Compact list of tagged items can not display variables about $this->item->event->beforeDisplayContent; [com_fields] Menu Compact list of tagged items can not display variables about $this->item->event->beforeDisplayContent; Dec 6, 2017
@shionphan
Copy link
Author

I had output in script console.log

4053aebb-3a40-40b1-89d2-38f42475d798

@stutteringp0et
Copy link
Contributor

how/why is this com_fields?

the events you have listed contain potential output of Joomla content plugins. If you don't have a plugin that injects afterDisplayTitle content - that property will be empty. Normally those are displayed for articles - but they can run in any context, and it's up to the template to render the data if it exists.

I'm looking at the /components/com_tags/views/tag/tmpl/list.php and list_items.php and those pages don't run content plugins on anything but the page description.

Now, if I look at /components/com_tags/views/tag/tmpl/default.php and default_items.php - that's a different story. Those templates run content plugins on the title, the description, the tag list description...

I don't think lists are ever meant to have plugin events for each item.

@shionphan
Copy link
Author

shionphan commented Dec 6, 2017

HI, @stutteringp0et

I hav modyfied the topic which is a mistake.

  1. Creat any tags and assign tags to a article.
  2. Creat Fields for this article in Articles manager. (Content - Articles - Fields)
  3. Creat a menu which is 'List of items that have been tagged with the selected tags.'
  4. Set Item Description as show in menu opition List Layouts
  5. Visit this page which creating by step 3.
  6. It dose not display any Fileds.

The Fields for article can not display in tags components page . We know that Fileds was content plugin for articles.

@shionphan shionphan changed the title [com_fields] Menu Compact list of tagged items can not display variables about $this->item->event->beforeDisplayContent; [com_tags] Menu Compact list of tagged items can not display variables about $this->item->event->beforeDisplayContent; Dec 6, 2017
@shionphan shionphan changed the title [com_tags] Menu Compact list of tagged items can not display variables about $this->item->event->beforeDisplayContent; [com_tags] Menu List of items that have been tagged with the selected tags can not display variables about $this->item->event->beforeDisplayContent; Dec 6, 2017
@stutteringp0et
Copy link
Contributor

The list view does not display fields. Maybe someone else can explain it to you.

@shionphan
Copy link
Author

@stutteringp0et

But I have found the code in components/com_tags/views/view.html.php, go to line 90.
I thinks it was for content plugins, EX. Fields.

foreach ($items as $itemElement)
{
	$itemElement->event = new stdClass;

	// For some plugins.
	!empty($itemElement->core_body)? $itemElement->text = $itemElement->core_body : $itemElement->text = null;

	$dispatcher = JEventDispatcher::getInstance();

	$dispatcher->trigger('onContentPrepare', array ('com_tags.tag', &$itemElement, &$itemElement->core_params, 0));

	$results = $dispatcher->trigger('onContentAfterTitle', array('com_tags.tag', &$itemElement, &$itemElement->core_params, 0));
	$itemElement->event->afterDisplayTitle = trim(implode("\n", $results));

	$results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tags.tag', &$itemElement, &$itemElement->core_params, 0));
	$itemElement->event->beforeDisplayContent = trim(implode("\n", $results));

	$results = $dispatcher->trigger('onContentAfterDisplay', array('com_tags.tag', &$itemElement, &$itemElement->core_params, 0));
	$itemElement->event->afterDisplayContent = trim(implode("\n", $results));

	// Write the results back into the body
	if (!empty($itemElement->core_body))
	{
		$itemElement->core_body = $itemElement->text;
	}
}

@ghost
Copy link

ghost commented Dec 6, 2017

calling @laoneo

@shionphan
Copy link
Author

@franz-wohlkoenig

Can you tell me directly?

@laoneo
Copy link
Member

laoneo commented Dec 6, 2017

The important thing here is the context. When you want to get the fields for articles, you need the context com_content.article. We are working here with tags ('com_tags.tag') which are different objects. If tags itself (you can create custom fields for a tag) would support custom fields, then they would get displayed.

When you want the custom fields for an article, you need to create an override of the view and then fetch the fields for the article trough the FieldsHelper::getFields() function.

@ghost
Copy link

ghost commented Dec 6, 2017

@shionphan I can't as i'm no Developer. @laoneo is the Developer of com_fields, thats why i called him.

@shionphan
Copy link
Author

@laoneo @franz-wohlkoenig

Thanks very much!
Thanks all!

@ghost
Copy link

ghost commented Dec 6, 2017

@shionphan if this Issue is solved, please close it.

@shionphan
Copy link
Author

shionphan commented Dec 6, 2017

@laoneo

I recommend adding this feature because of tag items display articles title and articles description. It should also display articles Fields.
I dont want it for com_tags

@laoneo
Copy link
Member

laoneo commented Dec 6, 2017

I quickly debugged the code, and we would have all relevant information which is needed for com_fields. So I suggest to leave this issue open till somebody comes up with a pr.

@shionphan
Copy link
Author

Got it.

@laoneo
Copy link
Member

laoneo commented Dec 6, 2017

Had a minute, so I created a pr. Please test #19006 which should fix the issue.

@joomla-cms-bot
Copy link

Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/18992

@ghost
Copy link

ghost commented Dec 6, 2017

closed as having Pull Request #19006

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants