Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Pages: [1] 2

Author Topic: [mini-MOD] Extra content mini mod  (Read 5827 times)

Pali

  • Full Member
  • ***
  • Karma: 16
  • Posts: 111
    • LE-PAVON
[mini-MOD] Extra content mini mod
« on: August 30, 2007, 12:12:07 pm »

Purpose of this minimod is pretty easy - control diaplayed extra content... We can show exact number of extra contects starting with exact extra content... :)

Styling of extra content is disabled in this MOD...

working with: snews 1.6, 1.5 (not tested)

Edited 31.8.07 - old code was working only wih Keyrocks sNews enhanced

just replace old extra function with this one:
Code: [Select]
//EXTRA CONTENT

function extra($start = 0, $size = 5) {

$categorySEF = get_id('category');

$categoryId = (check_category($categorySEF) == true || empty($categorySEF) || $categorySEF == l('home_sef')) ? 0 : retrieve('id', 'categories', 'seftitle', $categorySEF);

$pageSEF = get_id('article');

$pageId = (empty($categorySEF)) ? 0 : retrieve('id', 'articles', 'seftitle', $pageSEF);

$query = "SELECT * FROM ".db(prefix)."articles WHERE SUBSTRING(position, 1, 1) = '2' AND published = 1 ORDER BY id ASC LIMIT $start, $size";
       // use lines bellow if using sNews enhanced...
       // $query = "SELECT * FROM ".db(prefix)."".gl('articles_table')." WHERE SUBSTRING(position, 1, 1) = '2' AND published = 1 ORDER BY id ASC LIMIT $start, $size";

$result = mysql_query($query);

while ($r = mysql_fetch_array($result)) {

$pos = $r['position']; $pos_depend = substr($pos, 1, 1); $pos_artID = substr($pos, 2);

switch (true) {

case ($pos_depend == 0 && $categoryId == 0): $print = true; break;

case ($pos_depend == 1 && $categoryId == $pos_artID): $print = true; break;

case ($pos_depend == 2 && $pageId == $pos_artID): $print = true; $category = -1; break;

case ($pos_depend != '2' && $r['category'] == -1): $print = true; break; default: $print = false;

}

if ($print == true) {

echo $r['displaytitle'] == 'YES' ? '<h2>'.$r['title'].'</h2>' : '';
file_include($r['text'], 9999000);

echo $_SESSION[db('website').'Logged_In'] == token() ? '<p><a href="'.db('website').'index.php?action=admin_article&amp;id='.$r['id'].'" title="'.l('edit').' '.$r['seftitle'].'">'.l('edit').'</a></p>' : '';

if ($styleit == 1) {echo '</div>';}

}}}

Example of use:
We can divide the template in different blocks, where each block is represented with specified extra content like:
Code: [Select]
<div id="left">
<?php extra(1,1); ?> <!-- will show 1st extra content -->
</div>
<div id="center">
<?php center(); extra(2,1); ?> <!-- will show 2nd extra content -->
</div>
<div id="right">
<?php extra(3,2); ?> <!-- will show 2 extra contents starting with 3rd... -->
</div>

Very usefull in case of using philmozs "Auto function MOD"
« Last Edit: August 31, 2007, 09:46:38 pm by Pali »
Logged
I like sNews!

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
Re: [mini-MOD] Extra content mini mod
« Reply #1 on: August 30, 2007, 12:14:27 pm »

another addition so close to the previous, Pali... Nice. A request, though. As I'm a bit slow and don't always follow everyone's intentions in the posts. A demo would br great so that everyone, including me, understands, and furthermore, it's just dandy to have a demo. I like demo's.
« Last Edit: August 30, 2007, 12:20:27 pm by Patric Ahlqvist »
Logged
"It's only dead fish that goes with the flow... "
Updated

Pali

  • Full Member
  • ***
  • Karma: 16
  • Posts: 111
    • LE-PAVON
Re: [mini-MOD] Extra content mini mod
« Reply #2 on: August 30, 2007, 12:17:46 pm »

but how to show demo of this? it will looks like standard site... for example www.travelpoint.sk is using this...
Logged
I like sNews!

Rui Mendes

  • Development,Testing, Support
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1009
  • sNews1.7
    • Comunidade Portuguesa
Re: [mini-MOD] Extra content mini mod
« Reply #3 on: August 30, 2007, 11:06:18 pm »

Pali very produtivity today.
You win more 1 karma
 ;D
Logged
Need a Job on Europe. Linkdin - Facebook / Group

Joost

  • Guest
Re: [mini-MOD] Extra content mini mod
« Reply #4 on: August 31, 2007, 12:30:25 am »

but how to show demo of this? it will looks like standard site... for example www.travelpoint.sk is using this...
You are right of course. This mod is about control over the frontend using the backend (admin). This you cannot see just by looking at the frontend. But could you describe what it is doing in more detail?
If my guess is right, several extra's can be set to a page or category, but displayed on different locations in index.php, depending on the numbers: extra(1,1);
If it works the way I think, it is a simple yet powerful mod.

This is worth some good karmalizing! :D
Logged

Pali

  • Full Member
  • ***
  • Karma: 16
  • Posts: 111
    • LE-PAVON
Re: [mini-MOD] Extra content mini mod
« Reply #5 on: August 31, 2007, 11:35:55 am »

OK, i'll try  ;D

Example:
Site with 3 collumns will show:

LEFT collumn:
menu
1 extra content showed on all pages (ExC A)

CENTER collumn:
center function

RIGHR collumn:
all extra contents for particular category/pages (ExC other)
1 extra content showed on all pages (ExC B)

In administration we should create extra contents like this:
1. extra content A (all pages/categ.)
2. extra content B (all pages/categ.)
3. - X. other extra contents assigned to category or pages

index.php should contain this extra content codes:
LEFT:
<?php extra(0,1); ?> <!-- 1st extra content in database (smallest ID) -->

RIGHT:
<?php extra(2,1000); ?> <!-- all extra contents in database with 3rd or higher ID) and assigned for specific category/page -->
<?php extra(1,1); ?> <!-- 2nd extra content in database -->

Notes: counting starts with 0...
extra(x,y) will show y extra contents starting with ID x+1
original article IDs for extra contents can be 15, 16, 17 -> in our case its working like 1,2,3
Logged
I like sNews!

Joost

  • Guest
Re: [mini-MOD] Extra content mini mod
« Reply #6 on: August 31, 2007, 12:13:29 pm »

Thank you Pali, for explaining. I can now fully see what this mod can do. For instance:
Paste php extra(0,1); below
Code: [Select]
echo '<div class="commentsbox"><h2>'.l('contact').'</h2>';Set this extra content to 'Home' and you can edit Contact using the admin panel.
You can make exclusive content for archive and sitemap as well.
It is not a mini mod, it is a power mod with minimal coding. :)
« Last Edit: August 31, 2007, 12:36:35 pm by Joost »
Logged

Pali

  • Full Member
  • ***
  • Karma: 16
  • Posts: 111
    • LE-PAVON
Re: [mini-MOD] Extra content mini mod
« Reply #7 on: August 31, 2007, 04:10:20 pm »

thankx joost...

im adding extra info for contact form by other way...

I create new page, fill in additional data (company name, phone numbers, address) and at the end place this piece of code:
[func]contact[/func]

will work if you have philmozs Auto function MOD -> http://snewscms.com/forum/index.php?topic=4583.0 installed...

:D
Logged
I like sNews!

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
Re: [mini-MOD] Extra content mini mod
« Reply #8 on: August 31, 2007, 05:54:45 pm »

hey :)
i have installed this mod on local comp, it do not work for some reason,
added the function in the snews.php,
after i added the <?php extra(1,1); ?>  to the index.php
and preview the page, only the code befor the <?php extra(1,1); ?> call show up,
all code after the extra function call not working.

any idea why ?

thank you and awesme day

Pali

  • Full Member
  • ***
  • Karma: 16
  • Posts: 111
    • LE-PAVON
Re: [mini-MOD] Extra content mini mod
« Reply #9 on: August 31, 2007, 09:43:43 pm »

aaah, I see the problem (probably)... Im using Keyrocks sNews enhanced which has database tables as variables.. please, in function replace this:
Code: [Select]
".gl('articles_table')."

with this

Code: [Select]
articles

so the corresponding line will look like this:
Code: [Select]
$query = "SELECT * FROM ".db(prefix)."articles WHERE SUBSTRING(position, 1, 1) = '2' AND published = 1 ORDER BY id ASC LIMIT $start, $size";

Hope will help...

Orig. post updated..
« Last Edit: August 31, 2007, 09:47:29 pm by Pali »
Logged
I like sNews!

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
Re: [mini-MOD] Extra content mini mod
« Reply #10 on: August 31, 2007, 09:50:34 pm »

 ;D awesome, it works thank you  8)

it is a MEGA smart mod.
should be a part of snews core i think :)
it small and powerful and works great with standard 1.6

vgj Pali :)
good karma
« Last Edit: August 31, 2007, 10:07:55 pm by mosh »
Logged

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
Re: [mini-MOD] Extra content mini mod
« Reply #11 on: September 03, 2007, 02:23:15 am »

Another excellent addition! Well done Pali
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

Pali

  • Full Member
  • ***
  • Karma: 16
  • Posts: 111
    • LE-PAVON
Re: [mini-MOD] Extra content mini mod
« Reply #12 on: September 03, 2007, 08:27:38 am »

smart? can be smarter :)

just one extra field in database -> artorder and inserting blocks of extra content  will be easier.... (same principle as catorder for categories management)

anyway, exra contents can show any function via [func]nameoffunction:|:param1,param2...[/func] inserted directly into article text (Philmoz's mod)... can you see the power if you put there for example "<ul>[func]categories:|:1,5[/func]</ul>" ? [check this minimod ( http://snewscms.com/forum/index.php?topic=5783.0 )]... you can manage everything from backend...
Logged
I like sNews!

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
Re: [mini-MOD] Extra content mini mod
« Reply #13 on: September 06, 2007, 03:09:57 pm »

Hey Pali thanks for this SUPER MOD  :)
You must change the title from mini mod to super mod!!
« Last Edit: September 06, 2007, 03:11:33 pm by sibas »
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [mini-MOD] Extra content mini mod
« Reply #14 on: April 20, 2008, 02:30:46 am »

Pali, karma for you. You must comment last line of code because you disabled styling....

Anyway, I want someting related to your mod and I will start coding accordingly. I read EQ related post, Henrich wish, the new tables structure from 1.7RC version of sNews, Keyrocks posts, etc. and I will do this:

I will make/use the function like this:
<?php extra(1); ?>
<?php extra(2); ?>
<?php extra(3); ?>
.........................
<?php extra(n); ?>
everywhere I need a container (even in header, where I can easy change the image of header, or a random image). No more something like this:
<?php pages(); ?>
<?php menu_articles(0,10); ?>
<?php keyword_cloud(); ?>
........................................



Every container will contain infinite (teoreticaly) numbers of extras/functions/etc...
I will insert two fields (instead of only one) in table articles:
- extraid
- extraorder - content reordering is a MUST because you want to reorder content(categories under recent articles, and recent comments before site statistics  by example)

The table extras containing only two fields, id and name. No need of seftitle and description because these will never be used in links. Why? When you create a extra content, you can assign to it a container by his name, selected from a combobox. The name of container must by self explanatory (header, footer, top left sidebar, bottom left sidebar, top right sidebar, bottom right sidebar, before center, after center, etc....). Of course, a control panel for managing these containers, another one for reordering extra content by containers, etc....

I don`t think it will be complicated with so many great mods as example and with my recent experience with control panel for contact form but for sure, I don`t have the speed and experience of a snews dude. So, this is first a request.

What you think Joost, is what you looking for?

----------------------------------------------------
P.S. I don`t understand why we need styling inside containers. Because you insert extra() function in an already stylized index.php....if you want, you can style every separated extra content... but not required...
« Last Edit: April 20, 2008, 02:44:15 am by funlw65 »
Logged
Pages: [1] 2