CuteNews

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> [HACK] Have a "Sticky" Top Article, Have one post on top of the rest! Choosing a specific article.
John/Will
post Dec 14 2004, 10:39 PM
Post #1


CuteHack: Technician
***

Group: Support
Posts: 2,986
Joined: 3-July 04
From: Channel Islands
Member No.: 46



Name: "Sticky" Top Article
Author: EmoOnline
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Ever wanted to have one news post or article above all of the rest? ... Well ... This code below is the static version (aka you need to update via files not through cutenews!)
note: simpler alternative available here: Having Pinned/Important posts
In the next topic we'll discuss how to have 1 specific article on a page.
Instructions:
This hack exists in changing the CN Inlcude code, no CuteNews files need to be edited.
CODE
<?PHP
   $sticky = $_SERVER["REQUEST_URI"];
   if($sticky == "/" or $sticky== "/index.php")
   {
   echo "Some Text here<br /><br />";
   }
   /* And the following code is just the regular show news stuff. */
   $number = "5";
   include("cutenews/show_news.php");
   ?>


Ok the above shows "Some Text here" on your website and below this will show 5 news articles from your cutenews installation. Once you click on "read more" or "comment" the "Some Text Here" text will disappear. How does this work?

$sticky = $_SERVER["REQUEST_URI"];
Checks the referral, which, should be your homepage... forget about this, its important so dont change it tongue.gif

if($sticky == "/" or $sticky== "/index.php")
This is the part you can choose to change. The script gets the referral information from the line above.....checks it against your site and index.php (as above) and if your site has www.mysite.com/index.php or www.mysite.com then it will display the "some text here".

If your site is www.mysite.com/about.php it will not display "some text here" it is ONLY for the "RooT" of your website and the index.php page (which, you can change yourself).


CODE
<?PHP
   $sticky = $_SERVER["REQUEST_URI"];
   if($sticky == "/" or $sticky== "/index.php")
   {
$number="1";
$subaction="showfull";
$id="xxx"; // the id of the sticky article
$template="xxx";
$category="xxx";
include("news/show_news.php");
   }

   $number = "5";
   include("cutenews/show_news.php");
   ?>


Ok the above seems complicated....but lets break it down.....


$number="1";
shows one post....the sticky article

$subaction="showfull";
only for cutenews 1.x.x

$id="xxx";
The news id (very important) .... write a news article, add it, post it.....Now go to "edit news" and hover your mouse over the title or click on it...See the long number digit? .... its usually about 11 characters long (not hard to miss) . write that in place of the "xxx".

$template="xxx";
Make a template (if you want) and include it where the "xxx" is.

$category="xxx";
Make a category (if you want) and include it where the "xxx" is.

include("news/show_news.php");
The main include, essential.

With all the above correctly done, you can manage your new sticky topic through cutenews instead of it being static !! smile.gif
Go to the top of the page
 
+Quote Post
FUNimations
post Aug 17 2008, 01:18 PM
Post #2


CuteNews Support Crew Pimp
***

Group: Support
Posts: 16,501
Joined: 28-August 05
From: Belgium
Member No.: 5,662



Name: "Sticky" Top Article
Author: FUNimations
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: We'll discuss how to have 1 specific article on a page.
Instructions:
In the previous post the idea is to have other news as well that does not influence the 1 stickied.
But if you want just 1 specific article displayed on a page without using categories.
Something along the line of this should work better. And is easier to understand as less code is required then the example above.
CODE
$number="1";
if(!isset($_GET['subaction']) && !isset($_POST['subaction']))
$subaction="showfull";
$id="xxx"; // the id of the sticky article
$template="xxx";
$category="xxx";
$ucat = $category;
include("news/show_news.php");

the xxx's have the same value as in the previous post

$number="1";
shows one post....the sticky article

$subaction="showfull";
only for cutenews 1.x.x

$id="xxx";
The news id (very important) .... write a news article, add it, post it.....Now go to "edit news" and hover your mouse over the title or click on it...See the long number digit? .... its usually about 11 characters long (not hard to miss) . write that in place of the "xxx".

$template="xxx";

Make a template (if you want) and include it where the "xxx" is.

$category="xxx";
Make a category (if you want) and include it where the "xxx" is.

include("news/show_news.php");
The main include, essential.

if(!isset($_GET['subaction']) && !isset($_POST['subaction']))
this is the only code different from the above hack. This code is added in case want commenting on that article. As when you submit a comment, $subaction needs to be some other value.


--------------------

General FAQ
Spam Protection In Cutenews
Comments get deleted
_______________________
<< If you appreciate my help
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

 



RSS Lo-Fi Version Time is now: 21st May 2013 - 06:54 PM