Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2] 3

Author Topic: [MOD] Additional Article Position Options (sNews 1.5)  (Read 25699 times)

Keyrocks

  • Doug
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 451
  • Posts: 6290
  • Semantically Challenged
    • snews.ca
[MOD] Additional Article Position Options (sNews 1.5)
« Reply #15 on: December 08, 2006, 11:30:28 PM »

Quote from: Dom
P.S. Mika, maybe if you're working all day in front of your computer, you could benefit from using this - I know I would! This one wouldn't hurt either... :D
Wow... neat chairs... for a wheelbarrow of moolah. I'll have to stick with my $89.00 special. :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

david

  • Newbie
  • *
  • Karma: 0
  • Posts: 37
[MOD] Additional Article Position Options (sNews 1.5)
« Reply #16 on: December 18, 2006, 02:35:33 PM »

so easy,
keep up the good work!

I added the last line so I can see the title of second extra contents in admin:

Code: [Select]
#ADMINISTRATION LANGUAGE VARIABLES
#administration
$l['administration'] = 'Admin';
$l['articles'] = 'Articles';
$l['extra_contents'] = 'Extra contents';
$l['pages'] = 'Pages';
$l['second_extra_contents'] = 'Extra contents 2';
next: what to copy/paste and modify to have a 3d content?
Logged
peace, love,  fun and less pollution

Dom

  • Full Member
  • ***
  • Karma: 5
  • Posts: 166
    • domdelimar.com
[MOD] Additional Article Position Options (sNews 1.5)
« Reply #17 on: December 20, 2006, 10:00:17 PM »

I'm glad you found this useful and easy to apply. :)

That line you mention, BTW, should already be added at the end of all admin. language variables if you followed the instructions. So now you probably have two $l['second_extra_contents'] variables, not sure what this brings but if you wanted to have some other name for your 2nd extra content than the one I've chosen, sure you can change the value of any language variable.

About the 3rd extra function - it shouldn't be complicated and you should just replicate the steps but bare in mind you have to use another position instead of the position 9.

You see, default sNews has Articles, Pages and Extra Content which all differ in their position values: every entry in database (in table articles) with a position value of 1 is Article. If position value is 3, sNews will see it as a Page and if the position value starts with a number 2 (which can be followed by two or no additional digits) then sNews knows this entry has to be treated as Extra Content.

So the modified extra function (which shows Extra content just like function center shows Articles) has been renamed to second_extra and given the number 9 - so every entry in database that has the position value starting with number 9 (remember, the nature of extra content is that it can have up to three digits as a position value, unlike Article and Pages) will be treated as our NEW extra content, whatever we name it.

(I hope I haven't made any false claims here, but I'm sure people will correct me if I have.)

Why I chose number nine? Because I was afraid to use a two digit number. :) Can any of the PHP gurus tell me what consequences would a two digit number have here? Could it be done without further modifying the sNews engine?

Anyway, if you're about to build another extra function, I'd suggest you use number 8, to make your life easier in case any future version of sNews occupies more places (so far only places 1, 2 and 3 are "occupied").

Actually I went and quickly added the third extra function for you in a fresh snews.php file which you can download from here right now and test it.
I didn't have time to thoroughly test it but from a quick test I conducted it seems fine. Hope you can test it and use it if everything works as it should. If something doesn't work as it should, let me know. But before you do anything, backup your existing snews.php file and your MySQL database. ;)

EDIT: Sorry, wrong link posted - has been corrected.
Logged

Keyrocks

  • Doug
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 451
  • Posts: 6290
  • Semantically Challenged
    • snews.ca
[MOD] Additional Article Position Options (sNews 1.5)
« Reply #18 on: December 20, 2006, 10:18:33 PM »

A note about using double-digit position numbers: When I created the custom positions mod for 1.4, I also tested use of double-digits and it worked OK. I assume this doesn't present a problem because the ID number column in the articles table will accept 2 numbers as easily as one... and as long as the number used is also defined in all function-related strings throughout the snews.php file... they ought to work with it. I haven't tried a double-digit yet in 1.5 but it shouldn't be hard to test - just change all the 9s 10 20 or something to see what happens.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

david

  • Newbie
  • *
  • Karma: 0
  • Posts: 37
[MOD] Additional Article Position Options (sNews 1.5)
« Reply #19 on: December 20, 2006, 10:20:42 PM »

Dom, thank you for your kind reply and clear explanation
I see there is an xmas gift to download. :D
I'm so tired now and tomorrow will be very busy,
I will let you know in the next days

thanks
Logged
peace, love,  fun and less pollution

Datu Puti

  • Newbie
  • *
  • Karma: 0
  • Posts: 43
[MOD] Additional Article Position Options (sNews 1.5)
« Reply #20 on: December 21, 2006, 01:28:12 PM »

Thanks for the 3rd extra function Dom.. should prove useful.. i was looking at making extra_right extra_left extra_top extra_bottom..  :cool:
Logged
Regards from the beautiful 7000 Islands of the Philippines! Mabuhay!

Dom

  • Full Member
  • ***
  • Karma: 5
  • Posts: 166
    • domdelimar.com
[MOD] Additional Article Position Options (sNews 1.5)
« Reply #21 on: December 23, 2006, 03:12:05 PM »

Techyg, you're welcome. I still haven't thoroughly tested it and hope it works as it should.

Keyrocks, I don't have much time at the moment but I'm going to test this later. I don't know what led me to believe this wouldn't work as easily so that I haven't even tested it before...

Ilocoskid, I'm not sure what consequences this can bring, probably the reduction in speed if you have a really large snews.php file - I suggest you seek advice from someone more experienced with PHP than I am about this.

But if I were you, I'd ask myself whether I could accomplish whatever I want to accomplish without an extra function. You usually need an additional extra function if you want to present some manually inserted content at a different place in your website layout and all your existing extra functions are used to present something else at other places in your website layout.
Here's one example that I can think of now where you could use one of your extra functions but don't really have to: If you want to have AdSense boxes at the bottom of all of your articles. If you don't have that many articles, you can use the include function and include a file containing the AdSense code in each and every one of them.
Logged

Dom

  • Full Member
  • ***
  • Karma: 5
  • Posts: 166
    • domdelimar.com
[MOD] Additional Article Position Options (sNews 1.5)
« Reply #22 on: December 31, 2006, 10:12:24 PM »

Hmmm, nobody noticed this so far but it escaped me as well.
It appears I have left out the modification of the search function which is made so that the extra content doesn't show up in the search results. Since we added another extra content function here, the same logic should be applied and it also shouldn't show up in search results.

So, in your snews.php first locate "function search()".
Several lines down, inside this function, you'll find this line:
Quote
$query = "SELECT * FROM ".db('prefix')."articles WHERE SUBSTRING(position, 1, 1) != '2' AND published = 1 AND";
And replace it with this one (notice the change in blue):
Quote
$query = "SELECT * FROM ".db('prefix')."articles WHERE SUBSTRING(position, 1, 1) != '2' AND SUBSTRING(position, 1, 1) != '9' AND published = 1 AND";
If somebody tries to open one of your extra content from inside your search results page, they will just see "Content not found", so I advise you to apply this mod.

P.S. Original post modified with this addition.
Logged

Keyrocks

  • Doug
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 451
  • Posts: 6290
  • Semantically Challenged
    • snews.ca
[MOD] Additional Article Position Options (sNews 1.5)
« Reply #23 on: January 01, 2007, 12:04:26 AM »

Thanks Dom, appreciated. I had not tested the search on my added extra content yet. :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Datu Puti

  • Newbie
  • *
  • Karma: 0
  • Posts: 43
[MOD] Additional Article Position Options (sNews 1.5)
« Reply #24 on: January 01, 2007, 07:50:05 AM »

Fantastic work as usual Dom.. just a quick question.. i downloaded the snews.php file that you made available with the third extra function.. does the above patch fix it as well?
Logged
Regards from the beautiful 7000 Islands of the Philippines! Mabuhay!

brauck

  • sNews Dude
  • Hero Member
  • *****
  • Karma: 18
  • Posts: 572
    • http://www.hbw-webdesign.nl/
[MOD] Additional Article Position Options (sNews 1.5)
« Reply #25 on: January 01, 2007, 10:45:02 AM »

Thanks Dom  ;)
Logged
Confidence is reduced complexity.
brauck.nl for free css templates

Dom

  • Full Member
  • ***
  • Karma: 5
  • Posts: 166
    • domdelimar.com
[MOD] Additional Article Position Options (sNews 1.5)
« Reply #26 on: January 01, 2007, 05:51:37 PM »

Yes, I modified all the files I made available for download as well. If you downloaded it again after my last post then you have the latest patch included. (Quick test (applies only for this file): line 853 says as follows: "// Third: modified the following line:")
Logged

Dom

  • Full Member
  • ***
  • Karma: 5
  • Posts: 166
    • domdelimar.com
[MOD] Additional Article Position Options (sNews 1.5)
« Reply #27 on: January 01, 2007, 06:03:56 PM »

Quote from: ilocoskid
Fantastic work as usual Dom.. just a quick question.. i downloaded the snews.php file that you made available with the third extra function.. does the above patch fix it as well?
Oh, sorry. Only now I realized what you asked me... :)

No, that patch is only for the snews.php with the second extra function. If you downloaded the snews.php file with the third extra function as well, then you should do something similar to apply this patch:

In your snews.php first locate "function search()". Inside this function, find this line:
Quote
$query = "SELECT * FROM ".db('prefix')."articles WHERE SUBSTRING(position, 1, 1) != '2' AND published = 1 AND";
And replace it with this one (notice the change in blue):
Quote
$query = "SELECT * FROM ".db('prefix')."articles WHERE SUBSTRING(position, 1, 1) != '2' AND SUBSTRING(position, 1, 1) != '8' AND SUBSTRING(position, 1, 1) != '9' AND published = 1 AND";
Once again, note the above patch is only for you if you have two additional extra functions inside your sNews. Following the instructions inside the first post of this topic will only equip you with one additional extra function.
Logged

Datu Puti

  • Newbie
  • *
  • Karma: 0
  • Posts: 43
[MOD] Additional Article Position Options (sNews 1.5)
« Reply #28 on: January 02, 2007, 03:52:07 PM »

Great DOM.. thnx

 :cool:
Logged
Regards from the beautiful 7000 Islands of the Philippines! Mabuhay!

piXelatedEmpire

  • MIA
  • Thread Moderator
  • ULTIMATE member
  • *****
  • Karma: 37
  • Posts: 1454
  • currently MIA
[MOD] Additional Article Position Options (sNews 1.5)
« Reply #29 on: January 05, 2007, 07:52:18 AM »

ok, so I finally went ahead and installed this MOD, your instructions are FLAWLESS by the way :D

1 question tho, how do I edit this MOD so that the second Extra contents, when implemented, does not display in the admin panel? (see screenshot below)
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future
Pages: 1 [2] 3