- Posts: 37
COMMUNITY FORUM
Related Items
- Eyal Kattan
-
Topic Author
- Offline
- Junior Member
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
-
Topic Author
- Offline
- Junior Member
- Posts: 37
Eyal Kattan
Owner
MEDIA NEXUS INC
Please Log in or Create an account to join the conversation.
- Eyal Kattan
-
Topic Author
- Offline
- Junior Member
- Posts: 37
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
-
- Offline
- Senior Member
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
-
Topic Author
- Offline
- Junior Member
- Posts: 37
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
-
Topic Author
- Offline
- Junior Member
- Posts: 37
Eyal Kattan
Owner
MEDIA NEXUS INC
Please Log in or Create an account to join the conversation.
- Andrey Miasoedov
-
- Offline
- Senior Member
Please Log in or Create an account to join the conversation.
- Eyal Kattan
-
Topic Author
- Offline
- Junior Member
- Posts: 37
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
-
- Offline
- Senior Member
<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
-
Topic Author
- Offline
- Junior Member
- Posts: 37
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
-
- Offline
- Senior Member
Please Log in or Create an account to join the conversation.
- Eyal Kattan
-
Topic Author
- Offline
- Junior Member
- Posts: 37
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
Please Log in or Create an account to join the conversation.
- Eyal Kattan
-
Topic Author
- Offline
- Junior Member
- Posts: 37
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
-
- Offline
- Senior Member
Please Log in or Create an account to join the conversation.
- Eyal Kattan
-
Topic Author
- Offline
- Junior Member
- Posts: 37
Any thoughts?
Eyal Kattan
Owner
MEDIA NEXUS INC
Please Log in or Create an account to join the conversation.
- Yorb
-
- Offline
- New Member
- Posts: 10
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
-
Topic Author
- Offline
- Junior Member
- Posts: 37
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
-
Topic Author
- Offline
- Junior Member
- Posts: 37
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.
- Mark Matheson
-
- Offline
- New Member
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.
- Mark Matheson
-
- Offline
- New Member
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.