sriraag

[Solved 5r] BT Content Slider - Avoid showing current article

25 posts in this topic

Hello everyone,

The module "BT Content Slider" is simply amazing and I love it. But, i would like to avoid the current article i.e. the article where the module is being displayed to be avoided from the being shown in the module.

Please let me know as to how can this be achieved.

Thank you,

Sriraag

Share this post


Link to post
Share on other sites

Hi Sriraag.

If you use "Joomla Category" or "Joomla Article" source for the module you can use this solution

1. Open file /mod_bt_contentslider/classes/content.php

Find this line

$items = array();

add this block right below it

$jinput = JFactory::getApplication()->input;
$com = $jinput->getString('option');
$view = $jinput->getString('view');
$articleId = $jinput->getInt('id');

2. If you use "Joomla Category" source, find next line

if ($source == 'category') {

add right below it this block:

if($view == 'article' && $articleId && $com == 'com_content'){
$model->setState('filter.article_id', array($articleId));
$model->setState('filter.article_id.include', false); // Exclude
}

3. If you use Joomla Article ID source, find this

foreach ($ids as $id) {

Add right below it this block:

if($view == 'article' && $articleId && $com == 'com_content' && ((int) trim($id)) == $articleId){
continue;
}

4. Test it for working

I hope it work smoothly on your site :D

Muralidharreddy M likes this

Share this post


Link to post
Share on other sites

@tronghm that was simply wonderful! Thank you very much.I don't use Joomla Article ID Source, but for the Category - it definitely worked. :)

Now I have a small request. Is it possible to show all the articles in a category in this slider? So, without having to change the number of articles in "Source Setting" each time after I create a new article. i.e. Each time a new article is created, it is also shown in the slider, without me having to change any parameters.

If this is done, it would be a great help.

Thank you,

Sriraag

Share this post


Link to post
Share on other sites

Hai tronghm

Your explanation very good.i have same type of problem with this module but i want to hide all articles when click on any article in BT content show.And also is there any way to use HTML "target" attribute to show article in specified area in my website.I am waiting for reply.

Thank you

Share this post


Link to post
Share on other sites

Hi there.

Thanks for using our extensions.

I think your problem is same with this

It is menu item id problem

And with "target" attribute please take a look to the module manage page.

There is a parameter "Open Link In" in "Advanced Options" panel

You can use it as target.

Good luck.

Share this post


Link to post
Share on other sites

HI tronghm

Sorry for inconvenience you again and again.

The above solution is perfectly solution for my problem and this solution hide the article which present from BT content slide show but here i want to hide all articles in that module.Am having total 3 articles only in my module.

Thank you

Hi Sriraag.

If you use "Joomla Category" or "Joomla Article" source for the module you can use this solution

1. Open file /mod_bt_contentslider/classes/content.php

Find this line

$items = array();

add this block right below it

$jinput = JFactory::getApplication()->input;

$com = $jinput->getString('option');

$view = $jinput->getString('view');

$articleId = $jinput->getInt('id');

2. If you use "Joomla Category" source, find next line

if ($source == 'category') {

add right below it this block:

if($view == 'article' && $articleId && $com == 'com_content'){

$model->setState('filter.article_id', array($articleId));

$model->setState('filter.article_id.include', false); // Exclude

}

3. If you use Joomla Article ID source, find this

foreach ($ids as $id) {

Add right below it this block:

if($view == 'article' && $articleId && $com == 'com_content' && ((int) trim($id)) == $articleId){

continue;

}

4. Test it for working

Can i use above type of trick to hide all articles.i want hide only renaming two articles only

Thank you

Share this post


Link to post
Share on other sites

I am so confused with this sentences.

Can i use above type of trick to hide all articles.i want hide only renaming two articles only

You ask me you can use the trick to hide all articles.

But you said you want to hide only remaining two articles only.

I don't understand.

Share this post


Link to post
Share on other sites

sorry for my mistake.What i want to say is

i have total 3 articles in my bt content slide show.Using above trick i able to hide article which i opened in slide show but what i want is "i want to hide all articles from module".please tell me how to do that.

Share this post


Link to post
Share on other sites

I understand that "hide all articles form module" means "hide the module"

So the topic i gave you above to help you hide the module on article's detail page.

But if it is not really help you,

Please try this solution

Open file mod_bt_contentslider.php

find this line

$list = modBtContentSliderHelper::getList( $params, $module );

$context = JRequest::getString('option');
$view = JRequest::getString('view');
$hidden = false;
if($context == 'com_content' && $view == 'article'){
$id = JRequest::getInt('id');
foreach($list as $article){
if($article->id == $id){
$hidden = true;
break;
}
}
}

If you use k2 you can change context to k2 and view to item

Add new code right below it

Then bring all remain code below to this condition statement

if(!$hidden){

...

}

Of course, exclude last PHP close tag

?>

I hope it will help you

Muralidharreddy M likes this

Share this post


Link to post
Share on other sites

I tried this but no use.

here is my present mod_bt_contentslider.php file content.

kindly tell me if did any thing wrong.

Thank you

<?php

/**

* @package mod_bt_contentslider - BT ContentSlider Module

* @version 2.0.0

* @created Oct 2011

* @author BowThemes

* @email support@bowthems.com

* @website http://bowthemes.com

* @support Forum - http://bowthemes.com/forum/

* @copyright Copyright © 2012 Bowthemes. All rights reserved.

* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL

*

*/

// no direct access

defined('_JEXEC') or die('Restricted access');

require_once JPATH_SITE.'/modules/mod_bt_contentslider/helpers/helper.php';

//Get list content

$list = modBtContentSliderHelper::getList( $params, $module );

$context = JRequest::getString('option');

$view = JRequest::getString('view');

$hidden = false;

if($context == 'com_content' && $view == 'article'){

$id = JRequest::getInt('id');

foreach($list as $article){

if($article->id == $id){

$hidden = true;

break;

}

}

}

if(!$hidden){

//var_dump($list);

// ROW * COL

$itemsPerRow = (int)$params->get( 'items_per_rows', 3 );

$itemsPerCol = (int)$params->get( 'items_per_cols', 1 );

$moduleclass_sfx = $params->get('moduleclass_sfx');

$imgClass = $params->get('hovereffect',1)? 'class="hovereffect"':'';

$modal = $params->get('modalbox');

//Num of item display

$maxPages = $itemsPerRow*$itemsPerCol;

//Get pages list array

$pages = array_chunk( $list, $maxPages );

//Get total pages

$totalPages = count($pages);

// calculate width of each row. (percent)

$itemWidth = 100/$itemsPerRow;

$tmp = $params->get( 'module_height', 'auto' );

$moduleHeight = ( $tmp=='auto' ) ? 'auto' :(int)$tmp.'px';

$tmp = $params->get( 'module_width', 'auto' );

$moduleWidth = ( $tmp=='auto') ? 'auto': ((int)$tmp).'px';

$moduleWidthWrapper = ( $tmp=='auto') ? 'auto': (int)$tmp.'px';

//Get Open target

$openTarget = $params->get( 'open_target', '_parent' );

//auto_start

$auto_start = $params->get('auto_start',1);

//butlet and next back

$next_back = $params->get( 'next_back', 0 );

$butlet = $params->get( 'butlet', 1 );

//Option for content

$showReadmore = $params->get( 'show_readmore', '1' );

$showTitle = $params->get( 'show_title', '1' );

$show_category_name = $params->get( 'show_category_name', 0 );

$show_category_name_as_link = $params->get( 'show_category_name_as_link', 0 );

$showDate = $params->get( 'show_date', '0' );

$showAuthor = $params->get( 'show_author', '0' );

$show_intro = $params->get( 'show_intro', '0' );

//Option for image

$thumbWidth = (int)$params->get( 'thumbnail_width', 200 );

$thumbHeight = (int)$params->get( 'thumbnail_height', 150 );

$image_crop = $params->get( 'image_crop', '0' );

$show_image = $params->get( 'show_image', '0' );

$effect = $params->get('next_back_effect', 'slider') .','.$params->get('bullet_effect', 'slider');

$slideEasing = $params->get('effect', 'easeInQuad');

$preloadImg = JURI::root().'/modules/mod_bt_contentslider/tmpl/images/loading.gif';

$paging = $params->get( 'butlet', 0 )>0 ? 'true':'false';

$play = $auto_start?(int)$params->get('interval', '5000'):0;

$hoverPause = $params->get( 'pause_hover', 1 )>0? 'true':'false';

$duration = (int)$params->get('duration', '1000');

$autoHeight = $params->get( 'auto_height', 0 )>0?'true':'false';

$fadeSpeed = (int)$params->get('duration', '1000');

$modid = '#btcontentslider'.$module->id;

$touchScreen = $params->get('touch_screen', 0);

modBtContentSliderHelper::fetchHead( $params );

//Get tmpl

$align_image = strtolower($params->get( 'image_align', "center" ));

$equalHeight = $params->get( 'equalHeight', 0 ) > 0 && $align_image =='center' ?'true':'false';

require( JModuleHelper::getLayoutPath($module->module, $params->get('layout', 'default')));

}

?>

Share this post


Link to post
Share on other sites

Thanks tronghm

Now its working just changed sources from joomla categorises to joomla article id.

Thanks for your help :)

can you do a one more favour.see below image for details. if possible kindly do this for me.

image.jpg

Share this post


Link to post
Share on other sites

Hello.

Can you help me with the same issue (avoid to show current item in module at item's page) but for K2 category source?

Thanks/

Share this post


Link to post
Share on other sites

Hi please read my post again

Open file mod_bt_contentslider.php

find this line

$list = modBtContentSliderHelper::getList( $params, $module );

$context = JRequest::getString('option');

$view = JRequest::getString('view');

$hidden = false;

if($context == 'com_content' && $view == 'article'){

$id = JRequest::getInt('id');

foreach($list as $article){

if($article->id == $id){

$hidden = true;

break;

}

}

}

If you use k2 you can change context to k2 and view to item

:D

Share this post


Link to post
Share on other sites

Oh.

I'm really sorry, so shame.

Please use "com_k2" instead of only "k2"

if($context == 'com_k2' && $view == 'item'){

$id = JRequest::getInt('id');

foreach($list as $article){

if($article->id == $id){

$hidden = true;

break;

}

}

}

Share this post


Link to post
Share on other sites

Thank you for answer!

But after I've changed k2 to com_k2 module dissapeared at all :(

Looks like I found the solution for that :

if($context == 'com_k2' && $view == 'item'){

$id = JRequest::getInt('id');

foreach($list as $item){

if($item->id == $id){

$hidden = true;

break;

}

}

}

Just changed "article" to "item"

Thanks once more for your help!

Share this post


Link to post
Share on other sites

Can you please tell me how to hide the current article? I'm using Easyblog.

I've tried adding this code in easyblog.php but it throws an error saying that the setState () function does not exist.

Quote

if($view == 'article' && $articleId && $com == 'com_content'){
                $model->setState('filter.article_id', array($articleId));
                $model->setState('filter.article_id.include', false); // Exclude
            }

 

Share this post


Link to post
Share on other sites

Hi,

I'm using K2 categories, and trying to hide the pages the slider is on already.

For example, with 3 pages:

- if on page 1 it will show 2 and 3

- if on page 2 it will show 1 and 3

- if on page 3 it will show 1 and 2

 

.. I've read through the above posts and tried editing content.php, but am struggling to get this to work - please can you explain everything I need to do to achieve this?

I have only basic php knowledge so just want to know what to cut/paste and where.

Thank you!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now