Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

[solved] JDownloads -Hide a Module in a Category and the SubCategories

[solved] JDownloads -Hide a Module in a Category and the SubCategories

HI,

I have a problem i can not use this code here to hide a Module in  JDownloads in a specific category because some links on the website do not always have the "catid" in it:

Code:

if ( ! ( $option == "com_jdownloads" and

JRequest::getVar("catid") == "4" or
JRequest::getVar("catid") == "22" ) )
return 106;

Code:

http://localhost/index.php?option=com_jdownloads&Itemid=149&view=viewdownload&catid=22&cid=114

http://localhost/index.php?option=com_jdownloads&task=view.download&cid=114&Itemid=149

So i think the only way is to do it over MySQL query but i have really no idea on how to do this. sad

Edited By: Outbreaker
08-May-13 02:46:38

Outbreaker
Beginner Modder
ranks
useravatar
Offline
8 Posts
Administrator has disabled public posting

Re: [solved] JDownloads -Hide a Module in a Category and the SubCategories

Ok, I just downloaded jdownloads to see how the database is structured. Try this:

if ($option == 'com_jdownloads') {
  $catid = JRequest::getInt("catid", 0);
  $download_id = JRequest::getInt("cid",0);

  if ($catid == 0 and $download_id > 0) {
    $query = "select cat_id from #_".
    $query .= "_jdownloads_files where file_id = " . $download_id;
    $db->setQuery($query);
    $catid =$db->loadResult();
  }
  if ($catid == 1) return XXX;
  if ($catid == 2) return YYY;
  // etc.
  // Replace XXX, YYY etc with the module ids to return for each category.
}

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: [solved] JDownloads -Hide a Module in a Category and the SubCategories

Thank you this script works good i donated also 5 bucks for this. But i have still 2 noob questions. yikes
The first questions would be how could i change the script so that the module wont display in the JDownlands category's that i add in the script.
And the second questions would be how could i include a HTML script instead of an Module to this script.


This is the script i use now it would be good if we could include your script into this:

Code:

if ( ! ( $option == "com_search" ) )


if ( ! ( $option == "com_weblinks" and
JRequest::getVar("id") == "13" ) )

echo 'My HTML Code';

Outbreaker
Beginner Modder
ranks
useravatar
Offline
8 Posts
Administrator has disabled public posting

Re: [solved] JDownloads -Hide a Module in a Category and the SubCategories

answer to 1st question:

if ($option == 'com_jdownloads') {
  $catid = JRequest::getInt("catid", 0);
  $download_id = JRequest::getInt("cid",0);

  if ($catid == 0 and $download_id > 0) {
    $query = "select cat_id from #_".
    $query .= "_jdownloads_files where file_id = " . $download_id;
    $db->setQuery($query);
    $catid =$db->loadResult();
  }
  if ($catid != 1 and $catid != 2) return XXX;
  // Replace XXX with the module ids to NOT show if the item is in category 1 or 2.
}


Answer #2:

I'm not sure what you mean by integrating them. Are you saying you want to just echo some HTML instead of including the modules? Or as well as including the modules?

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: [solved] JDownloads -Hide a Module in a Category and the SubCategories

Yes exactly i would like to echo some HTML and Jave instead of including a module.

I know that this here would work:

Code:

if ($option == 'com_jdownloads') { 

  $catid = JRequest::getInt("catid", 0);
  $download_id = JRequest::getInt("cid",0);

  if ($catid == 0 and $download_id > 0) {
    $query = "select cat_id from #_".
    $query .= "_jdownloads_files where file_id = " . $download_id;
    $db->setQuery($query);
    $catid =$db->loadResult();
  }
  if ($catid != 1 and $catid != 2) echo 'My HTML and Java Code';
}

But i don't know how to add this code here to script as well:

Code:

if ( ! ( $option == "com_search" ) )


if ( ! ( $option == "com_weblinks" and JRequest::getVar("id") == "13" ) )

This means i like to run a Java script in the module but i don't want to run it on some JDownloads categories and in a Weblink category and on the Joomla Search page.

Outbreaker
Beginner Modder
ranks
useravatar
Offline
8 Posts
Administrator has disabled public posting

Re: [solved] JDownloads -Hide a Module in a Category and the SubCategories

ok, so instead of the return statement, you can put in a series of echo statements, best put inside {}.

e.g. instead of this:

return XXX;

put this:

{
  echo "<h3>Title here</h3>";
  echo "<p>content here</p>";
  // etc etc.
}

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: [solved] JDownloads -Hide a Module in a Category and the SubCategories

ok, assuming that you don't want to combine the original script with the new ones, you might do this:

if ( $option != "com_search"
  and ! ( $option == "com_weblinks" and JRequest::getVar("id") == "13" ) ) {
      echo "<script>.....</script>";
}

was that what you are after?

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: [solved] JDownloads -Hide a Module in a Category and the SubCategories

Thats's what i like to do. I'm only stuck at including the JDownloads script too. That's how i did it but it doesn't want to work.

Code:


if ( $option != "com_search"
and ! ( $option == "com_weblinks" and JRequest::getVar("id") == "13" )
and ($option == 'com_jdownloads') {
  $catid = JRequest::getInt("catid", 0);
  $download_id = JRequest::getInt("cid",0);
  if ($catid == 0 and $download_id > 0) {
    $query = "select cat_id from #_".
    $query .= "_jdownloads_files where file_id = " . $download_id;
    $db->setQuery($query);
    $catid =$db->loadResult();
  }
  if ($catid != 4 and $catid != 17)
}){
echo "test";
}

Outbreaker
Beginner Modder
ranks
useravatar
Offline
8 Posts
Administrator has disabled public posting

Re: [solved] JDownloads -Hide a Module in a Category and the SubCategories

Oh, I think I see what you are saying. You want the JS to appear on all pages except the following:

- com_search pages
- weblinks page 13
- jdownloads pages with category 4 or 17

So a little re-arranging of the code:

Code:

if ($option == "com_search") return; // short-circuit immediately!

if ( $option == "com_weblinks" and JRequest::getVar("id") == "13" ) return;

if ($option == 'com_jdownloads') {
  $catid = JRequest::getInt("catid", 0);
  $download_id = JRequest::getInt("cid",0);
  if ($catid == 0 and $download_id > 0) {
    $query = "select cat_id from #_".
    $query .= "_jdownloads_files where file_id = " . $download_id;
    $db->setQuery($query);
    $catid =$db->loadResult();
  }
  if ($catid == 4 or $catid == 17) return; // short-circuit
}

// if we got to here, then we know we're not on com_search,
// and we're not on com_weblinks item 13,
// and we're not on a jdownloads page on category 4 or 17.
echo "test";

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: [solved] JDownloads -Hide a Module in a Category and the SubCategories

Thanks this works now great. smile
The only thing i try to do now is to make another module with the same script above, but this time the script should redirect people to the registration page (index.php?option=com_comprofiler&task=registers).
I tried some methods but somehow i do it always wrong. hmm

Outbreaker
Beginner Modder
ranks
useravatar
Offline
8 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5913
Dormant:
User Info:
 
Total Users:
10796
Newest User:
mokao3
Members Online:
0
Guests Online:
189

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked