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.
Not a member yet? Click here to register.
Forgot Password?

Panel visible for the selected category news

Asked Modified Viewed 2,312 times
R
Ramage
R
Ramage 10
  • Junior Member, joined since
  • Contributed 11 posts on the community forums.
  • Started 7 threads in the forums
  • Started this discussions
asked
Junior Member

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

6 posts

K
KasteR
K
KasteR 10
  • Senior Member, joined since
  • Contributed 290 posts on the community forums.
  • Started 1 thread in the forums
answered
Senior Member

The variable you want to check is cat_id rather than news_cat_id

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
0 replies
R
Ramage
R
Ramage 10
  • Junior Member, joined since
  • Contributed 11 posts on the community forums.
  • Started 7 threads in the forums
  • Started this discussions
answered
Junior Member

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?
0 replies
K
KasteR
K
KasteR 10
  • Senior Member, joined since
  • Contributed 290 posts on the community forums.
  • Started 1 thread in the forums
answered
Senior Member

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:

$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.
0 replies
R
Ramage
R
Ramage 10
  • Junior Member, joined since
  • Contributed 11 posts on the community forums.
  • Started 7 threads in the forums
  • Started this discussions
answered
Junior Member

Great! Work perfect

ps. for others, this code have small bug, insert ; after echo "content here";
0 replies
— 4 years later —
Z
zizub
Z
zizub 10
  • Member, joined since
  • Contributed 156 posts on the community forums.
  • Started 29 threads in the forums
answered
Member

Quote


$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/PHPFusion/PHPFusio...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?
Edited by zizub on 18-05-2020 18:10,
1 reply
Z
zizub
Z
zizub 10
  • Member, joined since
  • Contributed 156 posts on the community forums.
  • Started 29 threads in the forums
answered
Member

Thanks for the explanation, I did not know that post (), get () ... is used only for the new cms PHPFusion 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
$ news_info ['news_cat'] == 20

Replaced by
$ news_info ['news_cat'] <> 20
Edited by zizub on 18-05-2020 20:06,
0 replies

Category Forum

Panels and Infusions

Labels

None yet

Statistics

  • Views 0 views
  • Posts 6 posts
  • Votes 0 votes
  • Topic users 4 members

4 participants

Z
Z
zizub 10
  • Member, joined since
  • Contributed 156 posts on the community forums.
  • Started 29 threads in the forums
K
K
KasteR 10
  • Senior Member, joined since
  • Contributed 290 posts on the community forums.
  • Started 1 thread in the forums
R
R
Anonymous User 367
  • Veteran Member, joined since
  • Contributed 939 posts on the community forums.
  • Started 2 threads in the forums
  • Answered 20 questions
R
R
Ramage 10
  • Junior Member, joined since
  • Contributed 11 posts on the community forums.
  • Started 7 threads in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet