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: A unique SEF link to browse a cat and its subcats in the home pages?  (Read 3421 times)

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web

Hello hello

I have to make it this way:
I gonna have a category coming with various sub-categories and I need to create such a link to allow people to browse through the home pages pagination process the cat, and its children, the kitties.
Eh eh... but how how?

Jokkman

  • Newbie
  • *
  • Karma: 4
  • Posts: 42
    • Ditsu
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #1 on: April 11, 2010, 01:01:11 am »

Do you mean that:

you have a category + child and you whant to create a diffrent sef link (your own, not the auto created) for "direct access" to  them or or parts of them.....? don t really understand, sorry

/Jokkman
Logged
Jokkman

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #2 on: April 11, 2010, 10:48:59 am »

Do you mean that:

you have a category + child and you whant to create a diffrent sef link (your own, not the auto created) for "direct access" to  them or or parts of them.....? don t really understand, sorry

/Jokkman
Hello Jokkman

Let me clear my thoughts:
I have a category called vegetable
and sub-categories tomatoes, beans, potatoes, etc.
when the user want to browse the articles in this category
he just click on such a link:
domain.com/vegetable/
But he doesn't see the sub-cats, right?
I'ld like such a link that would display the main category and its sub-categories.
So he would see a paginated home page with whole articles about tomatoes, beans, potatoes, etc.
That's it.

Jokkman

  • Newbie
  • *
  • Karma: 4
  • Posts: 42
    • Ditsu
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #3 on: April 11, 2010, 02:34:57 pm »

Do you mean that:

you have a category + child and you whant to create a diffrent sef link (your own, not the auto created) for "direct access" to  them or or parts of them.....? don t really understand, sorry

/Jokkman
Hello Jokkman

Let me clear my thoughts:
I have a category called vegetable
and sub-categories tomatoes, beans, potatoes, etc.
when the user want to browse the articles in this category
he just click on such a link:
domain.com/vegetable/
But he doesn't see the sub-cats, right?
I'ld like such a link that would display the main category and its sub-categories.
So he would see a paginated home page with whole articles about tomatoes, beans, potatoes, etc.
That's it.


Okidoki, if I have understand you right, something like this http://jokkmokk.biz/something.jpg
Its a comments script, but it can be aplyed on anything ....
(my URI/SEF to this is: http://mydomain.com/comments)
« Last Edit: April 12, 2010, 06:37:38 am by Jokkman »
Logged
Jokkman

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #4 on: April 12, 2010, 07:37:20 am »

Oh oh.... not sure...
this is a link to a cat:-http://on-air.hiseo.fr/liens/
it displays the articles in this category
the need is to have such SEF to display this category and its sub-categories all together.
Does your script provide such a page?

Jokkman

  • Newbie
  • *
  • Karma: 4
  • Posts: 42
    • Ditsu
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #5 on: April 12, 2010, 10:42:57 am »

Hi
If you use the thinking behind sNews TE (look in root index file for URI function) you can easy do this, no problem at all.
If you like contact me directly (use snews forum mail) and you get my private mail and I explain my thought behind the SEF solution

/Jokkman
Logged
Jokkman

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #6 on: April 12, 2010, 11:33:15 am »

Jokkman
each links (the one for comments and the one for the Mod's archive) leads to 404.

Jokkman

  • Newbie
  • *
  • Karma: 4
  • Posts: 42
    • Ditsu
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #7 on: April 12, 2010, 11:54:17 am »

I have send you my private mail by snews forum "personal message"
contact me and I explain

/Karl
« Last Edit: April 12, 2010, 11:56:47 am by Jokkman »
Logged
Jokkman

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #8 on: April 12, 2010, 01:15:40 pm »

PM? Why not keep the conversation here so others may chime in or learn from this?  Just my opinion.

Sven, you want the sub cat articles shown in the home page with the parent?   Do you want this within the main article section or in different sections?
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #9 on: April 12, 2010, 01:25:05 pm »

Hello Jason
PM? Why not keep the conversation here so others may chime in or learn from this?  Just my opinion.
I agree....
Sven, you want the sub cat articles shown in the home page with the parent?   Do you want this within the main article section or in different sections?
In the main section as per the basic home pages. No need to change.

Jokkman

  • Newbie
  • *
  • Karma: 4
  • Posts: 42
    • Ditsu
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #10 on: April 12, 2010, 05:57:19 pm »

The ”trick” is to use a “different” root index.php then standard (a modden one)
my latest index.php file, it has a lot of comments so I think you can understand the flow in it pretty easy. (from sNews TE 2.0)
You couldn’t se my jokkmokk.biz/comments because you weren’t logged on as admin on my site, I have a different gui for admin (gui theme) but in short the index file work like this:
It has snews.php included and run it first
Then It uses a function that’s checking what URI (sef) and then it call different index.php and style.css for each sef or just for one specific one.
You can download and test run sNews TE1.7 from the forum (http://snewscms.com/forum/index.php?topic=8507.0) if you want to test it

Code: [Select]
<?php 


/* Theme Edition 2.0 
unique style on pages, articles, categorys.....
based on sNews 1.7

/Jokkman
*/

// Get what is requested, path after mod rewrite
$tmp_URI GetCurrentURI();

// snews functions
include('snews.php');

// just a life belt for "the hands off" URI's
$HandsOffURI 0;

// res variables....
$Result_Style_Article '';
$Result_Style_Categories '';

//PostPageCategory ... variable
$PPCtype '0';
$R_A  '0';
$R_C  '0';
$unique_style '';


// get visitor mode, on off
$visit_view $_SESSION[_SITE.'Visitor_View'];

// 0 // for regular logged in view
// 1 // for visitor view

// switch function between visitor and admin mode
if ( $tmp_URI == switchmode 
{
$tmp_URI administration;
$visit_view $_SESSION[_SITE.'Visitor_View'];

// visit mode, on
if ($visit_view == 0
{
$_SESSION[_SITE.'Visitor_View'] = 1;
$ThemePath '';
include($ThemePath);
$SwitchPath _SITE;
}
// visit mode, off
else 
{
$_SESSION[_SITE.'Visitor_View'] = 0;
$SwitchPath _SITE.'snewste20/';
}
$visit_view $_SESSION[_SITE.'Visitor_View'];

$ThemePath 'themes/admintheme/index.php';
$cssPath site().'themes/admintheme/css/style.css';
$ThemeRoot  'themes/admintheme';
$InfoPath 'themes/admintheme/info/'
include($ThemePath); 

echo '<meta http-equiv="refresh" content="2; url='.$SwitchPath.'">';

// end switch mode

// if admin logon and visitor view = default eg:admin user
if (_ADMIN and $visit_view==0

/*
$_SESSION[_SITE.'Visitor_View'] = 0; // for regular logged in view
$_SESSION[_SITE.'Visitor_View'] = 1; // for visitor view
*/
$visit_view $_SESSION[_SITE.'Visitor_View'];

if ( $tmp_URI == snews_e_comments
{
$ThemePath 'themes/admintheme/comments.php';
$cssPath site().'themes/admintheme/css/style.css';
$ThemeRoot  'themes/admintheme';
$InfoPath 'themes/admintheme/info/'
include($ThemePath); 


// if admin logon, get admin theme (first time)
if ( $tmp_URI == administration
{
$ThemePath 'themes/admintheme/index.php';
$cssPath site().'themes/admintheme/css/style.css';
$ThemeRoot  'themes/admintheme';
$InfoPath 'themes/admintheme/info/'
include($ThemePath); 
$SwitchPath _SITE.'snewste20/';
echo '<meta http-equiv="refresh" content="2; url='.$SwitchPath.'">';


else {
// load admin panel of you are logged in and visitormode = 0 
If ($visit_view==0
{
// load admin theme
$ThemePath 'themes/admintheme/index.php';
$cssPath site().'themes/admintheme/css/style.css';
$ThemeRoot  'themes/admintheme';
$InfoPath 'themes/admintheme/info/'
include($ThemePath); 
}

}

}

else{
//regular view, visitor

//PostPageCategory position value in db for articles, 1= post/page, 2=category

// ----- check articles for style -------------------
$Query_Style ='SELECT count(seftitle) as CounterStyle FROM articles a where a.`seftitle` = "'.$tmp_URI.'" and visible="YES"';
$R_A CheckDBForURI($Query_Style);

if (
$R_A == '1') {
$PPCtype '1';
}
else {
$Query_Style 'SELECT count(seftitle) as CounterStyle FROM categories c where c.`seftitle` = "'.$tmp_URI.'" and published ="YES"';
$R_C CheckDBForURI($Query_Style);
if ($R_C == '1') {
$PPCtype '2';
}
}


// witch style do i get??
// 1= post/page, 2=category
// if i cant findit in db its a hands off URI and I load default style

if ($PPCtype == '1') {
// post/page style
$Query_Style ='SELECT `article_style` as CounterStyle FROM articles a where a.`seftitle` = "'.$tmp_URI.'"   and  visible="YES"';
$unique_style CheckDBForURI($Query_Style);
}

if (
$PPCtype == '2') {
// category style
$Query_Style 'SELECT categorie_style as CounterStyle FROM categories c where c.`seftitle` = "'.$tmp_URI.'"   and published ="YES"';
$unique_style CheckDBForURI($Query_Style);
}

$unique_style trim($unique_style);

// now we have style in "$unique_style" variable ex my_other_style.php
//$unique_style
if ($unique_style == '') {
// admin or hands off URI, load default index.php
$unique_style "index.php";
//makes path to theme based settings in adminpanel
$ThemePath 'themes/'.Trim(s('selected_theme')).'/'.$unique_style;
$cssPath site().'themes/'.s('selected_theme').'/css/style.css';
}
Else { 
// load our style 
//makes path to theme based settings in adminpanel
$ThemePath 'themes/'.Trim(s('selected_theme')).'/'.$unique_style.'.php';
$cssPath 'themes/'.Trim(s('selected_theme')).'/css/'.$unique_style.'.css';

if (file_exists($ThemePath)) {
if (file_exists($cssPath)) {
// loads unique css
$cssPath site().$cssPath;
} else {
// cant find unique css, load default
$cssPath site().'themes/'.s('selected_theme').'/css/style.css';
}

} else {
// file is missing...
$unique_style "index.php";
//makes path to theme based settings in adminpanel
$ThemePath 'themes/'.Trim(s('selected_theme')).'/'.$unique_style;
//makes css real path
$cssPath site().'themes/'.s('selected_theme').'/css/style.css';
}
}
}


//Theme Root
$ThemeRoot  'themes/'.Trim(s('selected_theme'));

// makes path to theme info
$InfoPath 'themes/'.Trim(s('selected_theme')).'/info/'

//include your selected theme
include($ThemePath); 

// res variables....
$Result_Style_Article '';
$Result_Style_Categories '';
//PostPageCategory ... variable
$PPCtype '0';
$R_A  '0';
$R_C  '0';
$unique_style '';



// -------------- Functions --------------------------------

Function GetCurrentURI() {
// get URI function
// if URI like p_% then its a "next page" and category template should be loaded

$originalString=$_SERVER['REQUEST_URI'];    
$newString Trim(str_replace("/"," ",$originalString)); 
$newString Trim(str_replace(" ","#",$newString)); 
$pos_staket strrpos($newString"#");
if ($pos === false) { // note: three equal signs
// not found...
}
$tot_length strlen($newString);
$stop_cut_value = ($tot_length $pos_staket);
$string_chunked substr($newString,$pos_staket,$stop_cut_value);
$string_chunked Trim(str_replace("#","",$string_chunked)); 

// start- nexpage fix

// checkif its a "next page" call
$pos2 strrpos($string_chunked'p_');
$pos3 strrpos($string_chunked'c_');

if ($pos2 === false and $pos3 === false) { // note: three equal signs
// not found... do nothing :-)
return $string_chunked;
}
ELSE {

// found... remove the p_xx or c_xx from URI and sendt complet uri again to function
$originalString2=$_SERVER['REQUEST_URI'];  
//replace p_xx in URI
$tmp_URI2 $string_chunked.'/';
$originalString2 Trim(str_replace($tmp_URI2," ",$originalString2)); 
$newString2 Trim(str_replace("/"," ",$originalString2)); 
$newString2 Trim(str_replace(" ","#",$newString2)); 
$pos_staket2 strrpos($newString2"#");
if ($pos === false) { // note: three equal signs
// not found...

}
$tot_length2 strlen($newString2);
$stop_cut_value2 = ($tot_length2 $pos_staket2);
$string_chunked2 substr($newString2,$pos_staket2,$stop_cut_value2);
$string_chunked2 Trim(str_replace("#","",$string_chunked2)); 

return $string_chunked2;

}

// stop- nextpage fix

//return $string_chunked;
}

// ---------------------------------------------------------------
Function CheckDBForURI($strSQL) {
// SQL select function

$Result_Style '';
// sql code for articles
$Query_Style $strSQL;
// call snews sql function
$Result_Style mysql_query($Query_Style);
$R_S mysql_fetch_assoc($Result_Style);
$result mysql_query($Query_Style);
//fetch tha data from the database
while ($row mysql_fetch_array($result)) {
$R_S $row{'CounterStyle'};
}
return $R_S;
}

// ---------------------------------------------------------------


?>

« Last Edit: April 12, 2010, 06:13:58 pm by Keyrocks »
Logged
Jokkman

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #11 on: April 13, 2010, 01:00:25 am »

Hello Jason
PM? Why not keep the conversation here so others may chime in or learn from this?  Just my opinion.
I agree....
Sven, you want the sub cat articles shown in the home page with the parent?   Do you want this within the main article section or in different sections?
In the main section as per the basic home pages. No need to change.

Sven, confirm that the sub cat articles will be within the main category articles (all that is needed, if I recall, would be a SQL change)

I think you will need some way to differentiate between what is what ( like a category: xx/xxx in the infoline for example) but I think it is doable.  Give me a few days (no promises, I am busy myself)
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #12 on: April 13, 2010, 08:31:11 am »

@ Jason:
Thanks a lot pal.

This is what I was thinking of (and trying to explain):



In my example there is no article in the main category, but VEGETABLE's cat can have articles of course...

Is this doable?

@ Karl:
That trick is smart and tough too... but I can't use it.... I have already 2 index pages splitted for public and admin and I don't manage different themes.
More, I have not enough PHP skills to make that run (I'm the inspecteur Clouzot of the sNews community).
Man, that was very kind of you: thanks a lot for sharing your ideas and code. ;)

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #13 on: April 14, 2010, 12:50:42 pm »

Untested and unoptimized - I have blood work soon and I haven't eaten so I am a bit grumpy (sorry!!!)

1. BACKUP!!
2. removing for error..... brb
« Last Edit: April 14, 2010, 01:10:47 pm by nukpana »
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #14 on: April 14, 2010, 12:58:08 pm »

Untested and unoptimized - I have blood work soon and I haven't eaten so I am a bit grumpy (sorry!!!)
No no no... Jason! You don't have to be sorry pal. I am indebted to you for the code you've provided.
Pretty soon I hope to show the result: I'm going to work on it after the end of the week.
Thanks a lot, again!
Pages: [1] 2