Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

Panel visible for the selected category news

Hello I dont know how to create panel visible on selected news category ex. category id 20.
CodeDownload  
if (isset($_GET['news_cat_id']) && $_GET['news_cat_id']==20) {
openside("Panel");
echo "content";   
closeside();
}

The variable you want to check is cat_id rather than news_cat_id

CodeDownload  
if (isset($_GET['cat_id']) && $_GET['cat_id']==20) {
openside("Panel");
echo "content";   
closeside();
}



Also consider that this feature is already included within the PHP Fusion CMS and custom code it not necessary.

Admin Panel > System Admin > Panels
When you edit your new panel, you'll see this area:
Panel Restriction:
Examples:
/news.php
/forum/index.php


For your example, you would enter this in the textarea:
/news_cats.php?cat_id=20

Also ensure this option is selected:
Include on these pages
Thanks for quick reply, but I must input this panel for ex. /news.php?readmore=336 (under subject).

If news category is 20 then show this panel. Can you help me?
Yes.

There may be a better way, but try something like this. If there's a better way, I'm sure someone will help, but perhaps this snippet might make things clearer with what you're asking for:

CodeDownload  
$news_id = $_GET['readmore'];

$result = dbquery("SELECT news_id, news_cat   FROM ".DB_NEWS." WHERE news_id = '".$news_id."'");
while ($data = dbarray($result)) {
   $news_info = array(
      "news_id" => $data['news_id'],
      "news_cat" => $data['news_cat']
   );         
}
      
if(isset($_GET['readmore']) && !empty($news_info['news_id']) && $news_info['news_cat'] == 20){
openside("Panel");
echo "content here" #place your code here
closeside();
}



This will lookup the news_cat based on the readmore id. Once you know that, then you can place your conditional statements.
Great! Work perfect

ps. for others, this code have small bug, insert ; after echo "content here";

Quote


CodeDownload  
$news_id = $_GET['readmore'];

$result = dbquery("SELECT news_id, news_cat   FROM ".DB_NEWS." WHERE news_id = '".$news_id."'");
while ($data = dbarray($result)) {
   $news_info = array(
      "news_id" => $data['news_id'],
      "news_cat" => $data['news_cat']
   );         
}
      
if(isset($_GET['readmore']) && !empty($news_info['news_id']) && $news_info['news_cat'] == 20){
openside("Panel");
echo "content here" #place your code here
closeside();
}



This code, needs a new standard, refusal from $ _GET or not?
I read the discussion at this address: https://github.com/php-fusion/PHP-Fus...ssues/2210
To connect the ad code, I want to create a separate panel and show it in only one category. In this code, do I need to rewrite the GET function or can I use it as it is?
New post(), get()... functions works only in 9.03.20 and above. But you can still use $_POST, $_GET etc..
Thanks for the explanation, I did not know that post (), get () ... is used only for the new cms PHP-Fusion 9.03.20 and higher.
If I need to do the opposite. Prevent the ad code from showing in one specific category. To do this, I will need to replace the == characters with angle brackets <>? So the panel should be shown in all categories except one specified (20).

I have to find
CodeDownload  
$ news_info ['news_cat'] == 20


Replaced by
CodeDownload  
$ news_info ['news_cat'] <> 20

Thread Information
Author
Replies
8 posts
Views
1354 times
Last Post
Last updated on 7 days ago
You can view all discussion threads in this forum.
You cannot set up a bounty in this discussion thread.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
You cannot up or down-vote on the post in this discussion thread.
Users who participated in discussion: zizub, KasteR, RobiNN, Ramage