Keyword

Related Items

  • Eyal Kattan
  • Eyal Kattan's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 5 months ago #60967 by Eyal Kattan
Related Items was created by Eyal Kattan
Hi All,

I am new to K2 so please spare me if I ask stupid questions. ;-)

I am trying to create a TAG based related items. I saw that by default, K2 shows the related items at the bottom of the page, right below the content area.

I am using a template that has a special position that I would like to use for the related items. How can I change the assigned position of the related items to the one defined by the template?

Or alternatively, I created a module that shows a category in this position but it doesn't filter the items based on Tags. Would it be easier to add filtration to this module? and how do I do this?

Thanks in advance.

-Eyal

Eyal Kattan
Owner
MEDIA NEXUS INC

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

  • Eyal Kattan
  • Eyal Kattan's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 5 months ago #60968 by Eyal Kattan
Replied by Eyal Kattan on topic Re: Related Items
Anyone can help?

Eyal Kattan
Owner
MEDIA NEXUS INC

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

  • Eyal Kattan
  • Eyal Kattan's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 5 months ago - 13 years 5 months ago #60969 by Eyal Kattan
Replied by Eyal Kattan on topic Re: Related Items
Ok, let try a different approach.

I created a new K2-Tools module for custom code. I copied the following code from item.php into the custom code text field in the module.

Now the page crashes in the browser. Obviously I'm missing something.

Can anyone help?

Thanks,

Eyal





<?php if($this->item->params->get('itemRelated') && isset($this->relatedItems)): ?>
<!-- Related items by tag -->
<ul>
<?php foreach($this->relatedItems as $key=>$item): ?>
<li class="<?php echo ($key%2) ? "odd" : "even"; ?>">

<?php if($this->item->params->get('itemRelatedImage')): ?>
<div class="itemRelImage"><?php echo $item->image; ?></div>
<?php endif; ?>

<?php if($this->item->params->get('itemRelatedTitle', 1)): ?>
<a class="itemRelTitle" href="<?php echo $item->link ?>"><?php echo $item->title; ?></a>
<?php endif; ?>
</li>
<?php endforeach; ?>
<li class="clr"></li>
</ul>

Eyal Kattan
Owner
MEDIA NEXUS INC

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

  • Andrey Miasoedov
  • Andrey Miasoedov's Avatar
  • Offline
  • Senior Member
More
13 years 5 months ago #60970 by Andrey Miasoedov
Replied by Andrey Miasoedov on topic Re: Related Items
Hello, Eyal.

Your last idea is not a true way, try DM K2 Related Articles module.

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

  • Eyal Kattan
  • Eyal Kattan's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 5 months ago - 13 years 5 months ago #60971 by Eyal Kattan
Replied by Eyal Kattan on topic Re: Related Items
Hi Andrey,

Thanks for your reply. Unfortunately I can't spend any more $$ on plug-ins because it feels like it just lead to purchasing another plugin and another plug-in.

The functionality I'm seeking is already in the basic K2 so I assumed it shouldn't be so hard to tweak it as I need. I even created an item page that shows the related items only. But when trying to use this template as sub-template, the page crashes. In fact, any template I use as sub-template in the module, even the default, crashes the page.

I am new to K2 and would like to better understand how it works and how it can be tweaked before I spend more money on plug-ins. But unfortunately there is no documentation and support on this forum has not showed it self yet. I apologize if I sound frustrated, but I am.

Eyal Kattan
Owner
MEDIA NEXUS INC

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

  • Eyal Kattan
  • Eyal Kattan's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 5 months ago #60972 by Eyal Kattan
Replied by Eyal Kattan on topic Re: Related Items
Really no one can help with this?

Eyal Kattan
Owner
MEDIA NEXUS INC

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

  • Andrey Miasoedov
  • Andrey Miasoedov's Avatar
  • Offline
  • Senior Member
More
13 years 5 months ago #60973 by Andrey Miasoedov
Replied by Andrey Miasoedov on topic Re: Related Items
You can use jQuery to replace related items to special position.

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

  • Eyal Kattan
  • Eyal Kattan's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 5 months ago #60974 by Eyal Kattan
Replied by Eyal Kattan on topic Re: Related Items

Andrey Miasoedov wrote: You can use jQuery to replace related items to special position.


IThanks for your reply Andrey. Since I'm relatively new to Joomla and K2 , can you ellaborate on how to do this? or post some links...

Thanks in advance

Eyal

Eyal Kattan
Owner
MEDIA NEXUS INC

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

  • Andrey Miasoedov
  • Andrey Miasoedov's Avatar
  • Offline
  • Senior Member
More
13 years 5 months ago #60975 by Andrey Miasoedov
Replied by Andrey Miasoedov on topic Re: Related Items
In your template's index.php, in <head> section add the following :

<script>

jQuery.noConflict();

jQuery(document).ready(function() {

var related = jQuery("div.itemRelated").html();
jQuery("div.itemRelated").html("");
jQuery("div.newItemRelated").html("<div class='itemRelated'>" + related + "</div>");

});

</script>

Relpace red text with your position container.

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

  • Eyal Kattan
  • Eyal Kattan's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 5 months ago - 13 years 5 months ago #60976 by Eyal Kattan
Replied by Eyal Kattan on topic Re: Related Items
doesn't seem to work. I think it is because the container into which I want to enter the related items html (according to your code) is only created if there is an actual module assigned to it.

Here is the code where it is getting created:

<?php if($this->countModules('position-45')): ?>
<div class="row1">
<jdoc:include type="modules" name="position-45" style="xhtml"/>
</div>
<?php endif; ?>


On another note, I may be aiming too high, but how complicated would it be to create a separated K2 component for Related Items? Then I can just use the Joomla admin interface to create a module and assign it to the Related Items component and the position I need.

Another thought, it seems like the related items could fit perfectly in the K2 Tools as an additional source type.

This way, I don't need to hard code the related items into the specific container.

Any thoughts?

Eyal Kattan
Owner
MEDIA NEXUS INC

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

  • Andrey Miasoedov
  • Andrey Miasoedov's Avatar
  • Offline
  • Senior Member
More
13 years 5 months ago #60977 by Andrey Miasoedov
Replied by Andrey Miasoedov on topic Re: Related Items
You need to manually add new container div to your template, jquery code tested on localhost - works great.

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

  • Eyal Kattan
  • Eyal Kattan's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 5 months ago - 13 years 5 months ago #60978 by Eyal Kattan
Replied by Eyal Kattan on topic Re: Related Items

Andrey Miasoedov wrote: You need to manually add new container div to your template, jquery code tested on localhost - works great.


Ok it works now. :)

However it introduced another problem. Now I'm getting the related items on every page of the site while I need to assign them to specific pages only.

Also, I modified the layout of the related items in item.php to show the image before the title. however it doesn't affect the section that I created with the JQuery. I attached 2 images that shows the correct formatting (relatedItems1) and the incorrect formatting (relatedItems2). Any ideas why the difference?

Here is how I created the container:

<div class="row1">
</div>

The "row1" is a class defined by my template.

Thanks,
Eyal.


Any more ideas?

Thanks,

Eyal

Eyal Kattan
Owner
MEDIA NEXUS INC
Attachments:

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

  • Eyal Kattan
  • Eyal Kattan's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 5 months ago #60979 by Eyal Kattan
Replied by Eyal Kattan on topic Re: Related Items
I did some testing and by placing the code for both creating the container and populating it with the related items in the K2 Custom Code tool and now I can actually control which items are assigned to this module - AWESOME!!!

Now I just need to figureout why the formatting is different (see images in my previous post).....

-Eyal

Eyal Kattan
Owner
MEDIA NEXUS INC

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

  • Andrey Miasoedov
  • Andrey Miasoedov's Avatar
  • Offline
  • Senior Member
More
13 years 5 months ago #60980 by Andrey Miasoedov
Replied by Andrey Miasoedov on topic Re: Related Items
The format becomes a different after jquery manipulations? It may be a css problem.

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

  • Eyal Kattan
  • Eyal Kattan's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 4 months ago #60981 by Eyal Kattan
Replied by Eyal Kattan on topic Re: Related Items
I see... so that puts me back in square 1. I think I'm going to try using Custom HTML module and insert some PHP code. if that works then I'll just null the Related Items html with JQuery....

Any thoughts?

Eyal Kattan
Owner
MEDIA NEXUS INC

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

More
13 years 4 months ago #60982 by Yorb
Replied by Yorb on topic Re: Related Items
jQuery is a pretty ugly way to do this, though yes of course it will work. :)

Have you tried this extension instead? It's free. Haven't played around with it much but I think it does exactly what you want. extensions.joomla.org/extensions/extension-specific/k2-extensions/13890

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

  • Eyal Kattan
  • Eyal Kattan's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 4 months ago - 13 years 4 months ago #60983 by Eyal Kattan
Replied by Eyal Kattan on topic Re: Related Items

Darwin wrote: j
Have you tried this extension instead? It's free. Haven't played around with it much but I think it does exactly what you want. extensions.joomla.org/extensions/extension-specific/k2-extensions/13890


This is definitely what I'm looking for but unfortunately it fails to work in Joomla 1.7.3
Looks like it need some L&A to make it work in J1.7x...

grrrrrrrrr......

Eyal Kattan
Owner
MEDIA NEXUS INC

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

  • Eyal Kattan
  • Eyal Kattan's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 4 months ago #60984 by Eyal Kattan
Replied by Eyal Kattan on topic Re: Related Items
I tried to contact the author of the K2 BNR Content modeule suggested by Darwin but have not received any response.

I decided to take a stub in trying to fix the K2 BNR Content module suggested Darwin. so far I was able to fix the XML file and the module opens up correctly with all properties in the admin console. It also save any selections I made.

The only problem remained still is that when I assign the page to the front page it crashes. I am sure some of the php needs to be modified to acommodate Joomla 1.7x and K2 2.5.x versions.
There are only 3 php files involved:

1. Helper.php
2. mod_k2bnr_content.php
3. default.php (template)

Would anyone here be interested to give me a hand in fixing this and make it available to the community?

Eyal Kattan
Owner
MEDIA NEXUS INC

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

More
13 years 4 months ago #60985 by Mark Matheson
Replied by Mark Matheson on topic Re: Related Items
I have had the same problem with the developer of K2 BNR Module.

In desperation, I have had a go at upgrading the module to work with Joomla 1.7/2.5. I have got it installing, can see all the setup options and have managed to get rid of the errors that appeared when I published it. However I am not getting any related items showing, even though there are definitely some related items.

If I get it resolved, I'll make the module available.

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

More
13 years 4 months ago #60986 by Mark Matheson
Replied by Mark Matheson on topic Re: Related Items
If anyone is still interested, I have developed a K2 Content module that allows you to show Related Items, and most other K2 content objects, in a module position.

It is waiting for approval on the JED and here in the K2 Extension list, but in the meantime, you can download K2 Split Content from here: -

www.marathonsoftware.com.au/products/k2-split-content

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


Powered by Kunena Forum