problems with embedded module

Free responsive Joomla 2.5 and 3.x module to present your content with easy and intuitive way.
Rate this topic: Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.
GK User
Fri Feb 03, 2012 2:38 pm
I use newsshowpro quite a bit, and love its flexibility. I also use extensively a custom photo presentation slideshow module. I will frequently embed the custom module in a K2 article by using the excellent modules anywhere plugin. Works great, and my customers love it.

The problem I am having is simply this - If the embedded slideshow appears in the first part of the article it is picked up as introductory text on newshowprow and an instance of the slideshow plays in the news show display.

I can use css selectors to set the display to none for the slideshow module only when it is inside of newshowpro, but the slideshow is still loading and running (and consuming bandwidth, loading time, etc) even though it is not displayed. If I have a newshowpro display which has 10 pages with arts, and each page has embedded slideshows, then I can have dozens of slideshows running invisibly and slowing things down.

Lately, i have been putting the slideshow in a different position, rather than embedding, so that Newshowpro doesn't pick it up. That works, but is kind of cumbersome - and adds a layer of difficulty that my customers struggle with.

What I really need to do is go back to embedding, but prevent the embedded module from being executed in Newshowpro. I have self imposed limits of not hacking the core, or another module. I have learned my lesson on the nightmare of maintenance once you start hacking.

So what I think I need is a way to detect if the slideshow module, which is embedded in a K2 article, is running inside of Newshowpro, or not. If I can detect it, I can easily write conditional code in my module to either execute or not execute the slideshow code. But I have not found a way to detect it.

I have looked at the getelementsbyid javascript function, but newshowpro has a dynamic id to allow for multiple instances on the same page. So i cant test for the ID as the id is not known until run time.

Any ideas? What code/function/test can I run to detect if a piece of code is running in a module, which is embedded in a K2 article, which is in turn displayed in newshowpro?
User avatar
Junior Boarder

GK User
Fri Feb 03, 2012 7:00 pm
I found a solution. Two solutions actually.

I love Gavick stuff, but their documentation is sparse. I had decided that I would have to hack the newshowpro module to strip out the {module....} phrase. As I was mucking around the code I found a preg_replace that was conditionally applied if "clean plugins" was on. So I went to the module and sure enough,there is a switch to turn off plugins. I turned it "on" and the modules anywhere insertion code was no longer in the newshowpro display. Thats all I had to do. (yes, I felt silly for not realizing the clean plugins switch was available and what it would do)

But I occasionally use other plugins which I do not want stripped.

if you want to hack the code so that only modules anywhere is stripped out,
then look in helper.php of the newsshowpro module for the line:

$news_textt = preg_replace("/\{.+?\}/", "", $news_textt);

and replace with:

$news_textt = preg_replace("/\{module.+?\}/", "", $news_textt);

then when the "clean Plugins" switch is turned on it will remove the modules anywhere reference, but leave others alone.
User avatar
Junior Boarder

teitbite
Sat Feb 04, 2012 1:55 am
Hi

That's a great way of solving it :)

I'm always using a css for that. Adding module code like this:

Code: Select all
<span class="nsp-hide">{module}</span>


and this in css:

Code: Select all
.nsp_main span.nsp-hide { display:none; }


but Your solution saves couple of minutes :)
User avatar
Moderator

GK User
Sun Feb 05, 2012 5:22 pm
teitbite wrote:Hi

That's a great way of solving it :)

I'm always using a css for that. Adding module code like this:

Code: Select all
<span class="nsp-hide">{module}</span>


and this in css:

Code: Select all
.nsp_main span.nsp-hide { display:none; }


but Your solution saves couple of minutes :)


That was my initial "fix". But display:none does not stop the slideshow from playing and consuming bandwidth - it just stops the display. To keep the page quick, and not burn needless bandwidth, I needed to prevent the module from loading.
User avatar
Junior Boarder

teitbite
Mon Feb 06, 2012 1:32 pm
Hi

Are You using any extention to make such constructions as {module} worki in other modules ? I had never played any plugin from inside. So this is why I'm telling about covering the string like "{module}" and not the working module :)

Honestly please tell me this extention's name. It may come in handy someday.
User avatar
Moderator

GK User
Mon Feb 06, 2012 8:03 pm
teitbite wrote:Hi

Are You using any extention to make such constructions as {module} worki in other modules ? I had never played any plugin from inside. So this is why I'm telling about covering the string like "{module}" and not the working module :)

Honestly please tell me this extention's name. It may come in handy someday.


I use modules anywhere to place modules inside of articles and K2 items. It can also be used to place on module inside of another. It is a great tool, but sometimes takes some extra work to get the formatting that you want.
User avatar
Junior Boarder

teitbite
Tue Feb 07, 2012 2:48 am
Hi

Och. I already know that module. But had to stop using it because of some problems I had with it. Anyway I think I'll try it again. It's been a couple of months, maby it got better :)

Thank You.
User avatar
Moderator


cron