PHP to display something in sNews ONLY when viewing an article on it's page

Comments (10)

Here is a snippet of PHP code for sNews 1.7 to display something (image, text, anything) ONLY when viewing an article on it's stand alone page, not on the home page, regular pages, or category views.

if (empty($currentPage) && !empty($_ID) && $_catID > 0) {
    echo "Sweet, this is an article page!";
} else {
    echo "Damn, this isn't an article page!";
}
bookmark / share this: Bookmark and Share
rated 4/5 (4 votes)


10 comments

Add a new comment »

alyoung alyoung said:
Apr 28th, 2009 at 6:03 pm

Thanks Matt :)

The best blog about sNews!


jordi jordi said:
Apr 29th, 2009 at 1:07 pm

Thanks!


Sven - Philippe Sven - Philippe said:
Apr 30th, 2009 at 3:07 am

Hi Matt,
really nice: I was wondering how I could display Google Ads too (later on) and tada! here comes the solution. Thanks a lot.
Have a nice day.


Matt Matt said:
Apr 30th, 2009 at 6:26 am

I would think your site has the potential to do very well with Adsense Philippe. You have a great niche site.


Sven - Philippe Sven - Philippe said:
Apr 30th, 2009 at 9:59 am

Thanks Matt for your encouragement.
But... but... this blog is just a playground for SEO and a way to let out the steam of my brain when I get ennoyed by customers.
I never done its promotion so there's a few visitors.


AJ AJ said:
Jun 20th, 2009 at 12:42 am

Matt,

This mod seems to be almost exactly what I am looking for. If you have the time could you explain how I can get something to show on my articles (as above) and also the homepage. My homepage is always my latest article. The something being adsense of course.

Thanks again for getting me sorted with my missing data last week.

Best,
Andrew


Matt Matt said:
Jun 20th, 2009 at 9:42 am

Hi Andrew,

That can be done, I'll get back to you on Tuesday... I'm away in Washington D.C. until then.

-Matt


Matt Matt said:
Jun 23rd, 2009 at 7:32 am

Andrew, try this and see if it works for what you want;

if (empty($currentPage) && (!empty($_ID) && $_catID > 0 || empty($_GET['category']))) {
    echo "Sweet, this is an article/home page!";
} else {
    echo "Damn, this isn't an article/home page!";
}


Andrew Andrew said:
Jun 28th, 2009 at 6:09 pm

Matt, I've been offline myself for a few days. Just noticed your back! I'll give your code a try. Thanks very much!


Sinolog Sinolog said:
Jan 22nd, 2010 at 1:26 pm


Write a comment

* = required field

:

:

:

:

You may insert urls in plain text, urls will be automatically linkified for trusted users and on seasoned posts only. All first comments are moderated, so use your email if you want to be remembered.


Back to top