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] 3 4 ... 9

Author Topic: Improve one function a week  (Read 21350 times)

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: Improve one function a week
« Reply #15 on: April 20, 2009, 04:48:16 PM »

ah, sacre bleu, mon ami's, hehe... french dude's talking is quite cool.

@ Joosty - Gotcha, and agrees.
@ Skian - Merci for the updates, and for your work... Nothing is so good that it cannot get better, eh.
Logged
My sNews site
"It's only dead fish that goes with the flow... "
Updated, online again - Free designs

Joost

  • Guest
Re: Improve one function a week
« Reply #16 on: April 22, 2009, 03:47:13 AM »

@ Skian,

Instead of function delete_category_all, this will probably (not tested) work as well:

Code: [Select]
<?php

case 'delete_category_all':
$q 'DELETE cat,art,com 
FROM '
._PRE.'categories AS cat
LEFT JOIN '
._PRE.'articles AS art ON category= cat.id
LEFT JOIN '
._PRE.'comments AS com ON articleid= art.id
WHERE cat.id='
.$id.' || subcat='.$id;
mysql_query($q);

?>
Logged

skian

  • Full Member
  • ***
  • Karma: 14
  • Posts: 120
Re: Improve one function a week
« Reply #17 on: April 22, 2009, 01:09:42 PM »


Code: [Select]
...DELETE cat,art,com

Nice improvement, i will test that.
But I would like to keep the code in a function because I plan to write test code. It is easier to test small function than monolithic code.
Logged

skian

  • Full Member
  • ***
  • Karma: 14
  • Posts: 120
Re: Improve one function a week
« Reply #18 on: April 26, 2009, 05:49:26 PM »

Simple code refactoring
Code: [Select]
<?php
// DISPLAY PAGES
function pages() {
function pages_li($url$text) {
global $categorySEF;
$class = ($categorySEF == $url) ? ' class="current"''';
if (!empty($url)) $url .= '/';
echo '<li><a'.$class.' href="'._SITE.$url.'">'.$text.'</a></li>';
}
pages_li(''l('home'));
pages_li('archive'l('archive'));
$qwr = !_ADMIN ' AND visible=\'YES\'' '';
$query "SELECT id, seftitle, title FROM "._PRE.'articles'." WHERE position = 3 $qwr ORDER BY artorder ASC, id";
$result mysql_query($query);
while ($r mysql_fetch_array($result)) {
if ($r['id'] != s('display_page')) {
pages_li($r['seftitle'], $r['title']);
}
}
pages_li('contact'l('contact'));
pages_li('sitemap'l('sitemap'));
}
?>
« Last Edit: April 27, 2009, 06:53:05 PM by skian »
Logged

skian

  • Full Member
  • ***
  • Karma: 14
  • Posts: 120
Re: Improve one function a week
« Reply #19 on: May 01, 2009, 07:08:32 PM »

This version of archive() behaves the same but performs one single sql query instead of two
Code: [Select]
<?php

function archive($start 0$size 200) {
echo '<h2>'.l('archive').'</h2>';
$query 'SELECT
title,a.seftitle AS asef,a.date AS date,
c.name AS name,c.seftitle AS csef,
x.name AS xname,x.seftitle AS xsef
FROM '
._PRE.'articles'.' AS a
LEFT OUTER JOIN '
._PRE.'categories'.' as c
ON category = c.id
LEFT OUTER JOIN '
._PRE.'categories'.' as x
ON c.subcat =  x.id
WHERE position = 1
AND a.published = 1
AND c.published =\'YES\'
AND (x.published =\'YES\' || x.published IS NULL)
ORDER BY date DESC
LIMIT '
."$start$size";
$result mysql_query($query);
$count mysql_num_rows($result);
if ($count === 0) {
echo '<p>'.l('no_articles').'</p>';
} else {
$month_names explode(', 'l('month_names'));
$dot l('divider');
echo '<p>';
while ($r mysql_fetch_array($result)) {
$year substr($r['date'], 04);
$month substr($r['date'], 52) -1;
$month_name = (substr($month01) == 0) ? $month_names[substr($month11)] : $month_names[$month];
if ($last <> $year.$month) {
echo '<strong>'.$month_name.', '.$year.'</strong><br />';
}
$last $year.$month;
$link = isset($r['xsef']) ? $r['xsef'].'/'.$r['csef'] : $r['csef'];
echo $dot.' <a href="'._SITE.$link.'/'.$r['asef'].'/">
'
.$r['title'].' ('.$r['name'].')</a><br />';
}
echo'</p>';
}
}


?>

Logged

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: Improve one function a week
« Reply #20 on: July 10, 2009, 08:38:31 AM »

May I add a revised function?

This code reduces 8 possible queries to 2 for this function

Code: [Select]
<?php

// ADMINISTRATION
function administration() {
   
if (!_ADMIN) {
echo( notification(1,l('error_not_logged_in'),'login'));
} else {
$q 'select 
(select count(id) from '
._PRE.'categories where published = "YES") as cat_count, 
(select count(id) from '
._PRE.'articles where position = 1 and published = 1) as art_count, 
(select count(id) from '
._PRE.'articles where position = 2 and published = 1) as extra_count,
(select count(id) from '
._PRE.'articles where position = 3 and published = 1) as page_count, 
count(id) as group_count from '
._PRE.'extras';
$res mysql_query($q);
$stat mysql_fetch_assoc($res);
// $catnum = mysql_fetch_assoc(mysql_query("SELECT COUNT(id) as catnum FROM "._PRE.'categories'.""));
foreach ($_POST as $key) {unset($_POST[$key]);}
echo '<div class="adminpanel">';
echo html_input('fieldset''''''''''''''''''''''''''','<a href="http://snewscms.com/" title="sNews CMS">sNews</a> '.l('administration'));
echo '<p>'.l('categories').': <a href="admin_category/">'.l('add_new').'</a>';
$link ' '.l('divider').' <a href="';
// if (stats('categories','') > 0) {
if ($stat['cat_count'] > 0) {
echo $link.'snews_categories/">'.l('view').'</a>';
}
echo '</p><p>'.l('articles').': ';
// $art_new = $catnum['catnum'] > 0 ? '<a href="article_new/">'.l('add_new').'</a>' : l('create_cat');
$art_new $stat['cat_count'] > '<a href="article_new/">'.l('add_new').'</a>' l('create_cat');
echo $art_new;
// if (stats('articles','1') > 0) {
if ($stat['art_count'] > 0) {
echo $link.'snews_articles/">'.l('view').'</a>';
}
echo '</p><p>'.l('pages').': <a href="page_new/">'.l('add_new').'</a>';
// if (stats('articles','3') > 0) {
if ($stat['page_count'] > 0) {
echo $link.'snews_pages/">'.l('view').'</a>';
}
echo '</p>';
if (s('enable_extras') == 'YES') {
echo '<div class="adminpanel2">';
echo html_input('fieldset'''''''''''''''''''''''''''l('extra_contents'));
echo '<p>'.l('groupings').': <a href="admin_groupings/">'.l('add_new').'</a>';
// if (stats('extras','') > 0) {
if ($stat['group_count'] > 0) {
echo $link.'groupings/">'.l('view').'</a>';
}
echo '</p>';
}
echo '<p>'.l('extra_contents').': <a href="extra_new/">'.l('add_new').'</a>';
// if (stats('articles','2') > 0) {
if ($stat['extra_count'] > 0) {
echo $link.'extra_contents/">'.l('view').'</a>';
}
echo '</p>';
if (s('enable_extras') == 'YES') {
echo '</fieldset></div>';
}
echo '</fieldset></div>';
$q_comm 'select 
c.id, c.articleid, c.name, a.title as articleTitle 
from '
._PRE.'comments as c 
left outer join '
._PRE.'articles as a 
on c.articleid = a.id 
where c.approved != "True"'
;
// $query_comm = 'SELECT id,articleid,name FROM '._PRE.'comments'.' WHERE approved != \'True\'';
// $result_comm = mysql_query($query_comm);
$result_comm mysql_query($q_comm);
$unapproved mysql_num_rows($result_comm);
if ($unapproved 0) {
echo '<div class="adminpanel">';
echo html_input('fieldset'''''''''''''''''''''''''''l('comments'));
echo '<p><a onclick="toggle(\'sub1\')" style="cursor: pointer;" title="'.l('unapproved').'">
'
.$unapproved.' '.l('wait_approval').'</a></p>';
echo '<div id="sub1" style="display: none;">';
while ($r mysql_fetch_array($result_comm)) {
// $articleTITLE = retrieve('title', 'articles', 'id', $r['articleid']);
// echo '<p>'.$r['name'].' (<strong>'.$articleTITLE.'</strong>) '.l('divider').'
// <a href="'._SITE.'?action=editcomment&amp;commentid='.$r['id'].'">'.l('edit').'</a></p>';
echo '<p>'.$r['name'].' (<strong>'.$r['articleTitle'].'</strong>) '.l('divider').'
<a href="'
._SITE.'?action=editcomment&amp;commentid='.$r['id'].'">'.l('edit').'</a></p>';
}
echo '</div></fieldset></div>';
}
echo '<div class="adminpanel">';
echo html_input('fieldset'''''''''''''''''''''''''''l('site_settings'));
echo '<p><a href="snews_settings/">'.l('settings').'</a></p>
<p><a href="snews_files/">'
.l('files').'</a></p></fieldset></div>
<div class="adminpanel">'
;
echo html_input('fieldset'''''''''''''''''''''''''''l('login_status'));
echo '<p><a href="logout/">'.l('logout').'</a></p></fieldset></div>';
}
}

?>

Logged

centered

  • Guest
Re: Improve one function a week
« Reply #21 on: July 10, 2009, 06:52:11 PM »

(nukpana is my evil split personality depending on which browser has my login information... anyway)

In snLite, I used unobtrusive javascript for some admin functions. Perhaps I will work up some for sNews.

snLite example:
Code: [Select]
/* in Template header... */
<?php 
global 
$gbl;
// if logged in and is a content add or edit form
if (__admin && ($gbl['uri'][2] == 'add' || $gbl['uri'][2] == 'edit')) { ?>

<script type="text/javascript">
//<![CDATA[
var allowsef = /new|add|_ar|_ca/.test("new");

// generate SEF urls
function nameField() {
if (allowsef == true) {
var n = document.getElementById('adminNameField');
var u = document.forms['post'].uri;
n.onchange = function(){ genSEF(n,u); };
n.onkeyup = function(){ genSEF(n,u); };
}
}
function genSEF(from,to) {
if (allowsef == true) {
var str = from.value.toLowerCase();
str = str.replace(/[^a-z 0-9]+/g,'');
str = str.replace(/\s+/g, "-");
to.value = str;
}
}
window.onload=function(){
nameField();
}
//]]>
</script>
<?php 
// ie if logged in and url is a content edit form & id is not Home
if (__admin && $gbl['uri'][2] == 'edit' && $gbl['uri']['id'] != 1) { ?>

<script type="text/javascript">
//<![CDATA[
// delete warnings
function deleteButton() {
var d = document.getElementById('deleteContent');
d.onclick = function(){ return pop(); };
}
function pop() {
var agree=confirm("Are you sure you want to delete this?");
if (agree) {
return true;
} else {
return false;
}
}

window.onload=function(){
deleteButton();
}
//]]>
</script>
<?php 

// In admin page
<p>
<label for="adminNameField">'.ucfirst($type).' Name:</label>
<input type="text" name="name" id="adminNameField" value="'.$name.'" />
</
p>
<
p>
<label for="adminURIField">Search engine name:</label>
<input type="text" name="uri" id="adminURIField" value="'.$uri.'" />
</
p>
Logged

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: Improve one function a week
« Reply #22 on: August 12, 2009, 12:47:31 PM »

To replace function tags

Code: [Select]
<?php
/*
$tags = array(
'infoline' => '<p class="date">,readmore,comments,date,edit,</p>',
'comments' => '<p class="meta">,name, '.l('on').' ,date,edit,</p>,<p class="comment">,comment,</p>'
);

function tags($tag) {
global $tags;
return $tags[$tag];
}
*/

function post_infoline($date$readmore$comments$edit) {
$date  = (!empty($date)) ? $date '';
$readmore  = (!empty($readmore)) ? $readmore '';
$comments  = (!empty($comments)) ? $comments '';
$edit  = (!empty($edit)) ? $edit '';
return $date $readmore $comments $edit;
}

function 
comment_infoline($date$name$comment$edit) {
$date  = (!empty($date)) ? $date '';
$name  = (!empty($name)) ? $name '';
$comment  = (!empty($comment)) ? $comment '';
$edit  = (!empty($edit)) ? $edit '';
return '<p class="meta">'.$name .' '.l('on').' '$date $edit .'</p><p class="comment">'.$comment.'</p>';
}
?>


Down in function articles comment this block out:
Code: [Select]
if (!empty($currentPage)) {
if ($infoline == true) {
$tag = explode(',', tags('infoline'));
foreach ($tag as $tag) {
switch (true) {
case ($tag == 'date'):
echo $a_date_format;
break;
case ($tag == 'readmore' && strlen($r['text']) > $shorten):
echo $link.$uri.'/'.$r['asef'].'/">'.l('read_more').'</a> ';
break;
case ($tag == 'comments' && ($commentable == 'YES' || $commentable == 'FREEZ')):
echo $link.$uri.'/'.$r['asef'].'/#'.l('comment').'1">
'.l('comments').' ('.$comments_num.')</a> ';
break;
case ($tag == 'edit' && _ADMIN):
echo ' '.$edit_link;
break;
case ($tag != 'readmore' && $tag != 'comments' && $tag != 'edit'):
echo $tag;
break;
}
}
} else if (_ADMIN) {
echo '<p>'.$edit_link.'</p>';
}
} else if (empty($currentPage)) {
if ($infoline == true) {
$tag = explode(',', tags('infoline'));
foreach ($tag as $tag ) {
switch ($tag) {
case 'date':
echo $a_date_format;
break;
case 'readmore':
case 'comments': ;
break;
case 'edit':
if (_ADMIN) {
echo ' '.$edit_link;
}
break;
default:
echo $tag;
}
}
} else if (_ADMIN) {
echo '<p>'.$edit_link.'</p>';
}
}
}

Replace with:
Code: [Select]
if ($infoline == true) {
$infoClass = ' class="date"';
$readMore = !empty($currentPage) && (strlen($r['text']) > $shorten) ?
' '.$link.$uri.'/'.$r['asef'].'/">'.l('read_more').'</a> ' : '';
$commentLine = !empty($currentPage) && ($commentable == 'YES' || $commentable == 'FREEZ') ?
$link.$uri.'/'.$r['asef'].'/#'.l('comment').'1">'.l('comments').' ('.$comments_num.')</a> ' : '';
$dateLine = $a_date_format;
}
$editLink =  _ADMIN ? ' '.$edit_link : '';
$informationLine = post_infoline($dateLine, $readMore, $commentLine, $editLink);
echo '<p'.$infoClass.'>'.$informationLine.'</p>';

In Comments find this:
Code: [Select]
$tag = explode(',', tags('comments'));
foreach ($tag as $tag) {
switch (true) {
case ($tag == 'date'):
echo '<a id="'.l('comment').$commentNum.'"
name="'.l('comment').$commentNum.'"></a>'.$date;
break;
case ($tag == 'name'):
$name = $r['name'];
echo !empty($r['url']) ?
'<a href="'.$r['url'].'" title="'.$r['url'].'" rel="nofollow">
'.$name.'</a> ' : $name;
break;
case ($tag == 'comment'):
echo $r['comment'];
break;
case ($tag == 'edit' && _ADMIN):
echo $edit_link.'editcomment&amp;commentid='.$r['id'].'"
title="'.l('edit').' '.l('comment').'">'.l('edit').'</a> ';
echo $edit_link.'process&amp;task=deletecomment&amp;commentid='.$r['id'].'"
title="'.l('delete').' '.l('comment').'" onclick="return pop()">'.l('delete').'</a>';
break;
case ($tag == 'edit'): ;
break;
default:
echo $tag;
}
}

Replace with:
Code: [Select]
$infoLineDate = '<a id="'.l('comment').$commentNum.' "name="'.l('comment').$commentNum.'"></a>'.$date;
$infoLineName = !empty($r['url']) ? '<a href="'.$r['url'].'" title="'.$r['url'].'" rel="nofollow">'.$r['name'].'</a> ' : $r['name'];
$infoLineEdit = _ADMIN ? $edit_link.'editcomment&amp;commentid='.$r['id'].'" title="'.l('edit').' '.l('comment').'">'.l('edit').'</a> '.$edit_link.'process&amp;task=deletecomment&amp;commentid='.$r['id'].'" title="'.l('delete').' '.l('comment').'" onclick="return pop()">'.l('delete').'</a>' : '';
echo comment_infoline($infoLineDate, $infoLineName, $r['comment'], $infoLineEdit);


*** edit... some thinking... I am not feeling this rewrite...
« Last Edit: September 30, 2009, 11:45:48 PM by nukpana »
Logged

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: Improve one function a week
« Reply #23 on: August 20, 2009, 07:05:53 AM »

Code: [Select]
<?php
/** Add function **/
// Remove null & emtpy variables from array
function array_remove$var ) {
foreach($var as $key => $value) {
if (!isset($value) || empty($value)) {
unset($var[$key]);
}
}
return $var;
}


if (!empty(
$_GET['category'])) {
$url explode('/'clean($_GET['category'])); 
// eq start adding

// remove the unneeded keys that the end slash created
$url array_remove$url ); 
// unset any part of the array after /cat/subcat/art/comment/
foreach ($url as $key=>$value) { 
if ($key 3) unset($url[$key]);
}
// eq end adding
$categorySEF $url[0];
// eq edit - I think this really should be an if/else statement here
if (isset($url[1]) && substr($url[1], 01) == l('comment_pages') && is_numeric(substr($url[1], 11))) {
$commentsPage $url[1];
} else {
$subcatSEF $url[1];
}
// if (isset($url[1])) $subcatSEF = $url[1];
// if (substr($url[1], 0, 1) == l('comment_pages') && is_numeric(substr($url[1], 1, 1))) $commentsPage = $url[1];
if (isset($url[2]))  $articleSEF$url[2];
if (isset($url[3])) $commentsPage $url[3];
?>

Logged

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: Improve one function a week
« Reply #24 on: September 12, 2009, 06:28:46 AM »

Function l(anguage)

Code: [Select]
<?php
// Language Variables
function l($var) {
global $l;
/*** SYSTEM VARIABLES (not to be translated) ***/

// SEF links of the hardcoded items - RESERVED WORDS - will clash if using for article/category seftitles.
$l['cat_listSEF'] = array(
'archive',
'contact',
'sitemap',
'login'
);
if ( _ADMIN ) {
$l['adminlistSEF'] = array(
'administration',
'admin_category',
'admin_article',
'article_new',
'extra_new',
'page_new',
'snews_categories',
'snews_articles',
'extra_contents',
'snews_pages',
'snews_settings',
'snews_files',
'logout',
'groupings',
'admin_groupings'
);
$l['cat_listSEF'] = array_merge$l['cat_listSEF'], $l['adminlistSEF'] ); 
}
//divider character
$l['divider'] = '&middot;';
// used in article pagination links
$l['paginator'] = 'p_';
$l['comment_pages'] = 'c_';
// list of files & folders ignored by upload/file list routine
$l['ignored_items'] = array(
'.',
'..',
'cgi-bin',
'.htaccess',
'Thumbs.db',
'snews.php',
'index.php',
'lib.php',
'style.css',
'admin.js',
'".s("language").".php' 
);
return $l[$var];
}

?>


This replaces this:
Code: [Select]
<?php
// LANGUAGE VARIABLES
s('language') != 'EN' && file_exists('lang/'.s('language').'.php') == true 
? include(
'lang/'.s('language').'.php'
: include('lang/EN.php');
// SYSTEM VARIABLES (not to be translated)
//SEF links of the hardcoded items - RESERVED WORDS - will clash if using for article/category seftitles.
$l['cat_listSEF'] = 'archive,contact,sitemap,login';
if (_ADMIN) {$l['cat_listSEF'] .= ',administration,admin_category,admin_article,article_new,extra_new,page_new,snews_categories,snews_articles,extra_contents,snews_pages,snews_settings,snews_files,logout,groupings,admin_groupings';}
//divider character
$l['divider'] = '&middot;';
// used in article pagination links
$l['paginator'] = 'p_';
$l['comment_pages'] = 'c_';
// list of files & folders ignored by upload/file list routine
$l['ignored_items'] = '.,..,cgi-bin,.htaccess,Thumbs.db,snews.php,index.php,lib.php,style.css,admin.js,'.s('language').'.php';

?>


And now every explode(',',l('cat_listSEF')) can be changed to simply l('cat_listSEF')
« Last Edit: September 12, 2009, 11:43:55 AM by nukpana »
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Re: Improve one function a week
« Reply #25 on: September 12, 2009, 11:46:34 AM »

Not sure if this is a bug, but in testing I can make a page called article new with a sefTitle of article_new.... If logged in the user made article_new is directed to the admin page not the user page....
Oversight/bug.
But, how are you able to ... aaaah, yes, likewise a category, if you manually edit the seftitle field.

looks like we need some extra separation and checking.
Logged
Of all the things I have lost, it is my mind that I miss the most.

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: Improve one function a week
« Reply #26 on: September 12, 2009, 12:29:08 PM »

Not sure if this is a bug, but in testing I can make a page called article new with a sefTitle of article_new.... If logged in the user made article_new is directed to the admin page not the user page....
Oversight/bug.
But, how are you able to ... aaaah, yes, likewise a category, if you manually edit the seftitle field.

looks like we need some extra separation and checking.

Upon reviewing, I do not see any checking against the cat_listSEF for a page/category in processing.

I am not sure what you mean by extra separation...

I like this...

Code: [Select]
if ( $url[0] == 'sNewsAdmin' && !_ADMIN) {
   unset( $url );
   $categorySEF = '404';
} else $categorySEF = $url[0];

Code: [Select]
if ( _ADMIN && $url[0] == 'sNewsAdmin' && in_array( $url[1], l( 'cat_listSEF') ) {
   // do admin function...
}
Logged

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: Improve one function a week
« Reply #27 on: October 08, 2009, 01:27:10 PM »

Back on track....

Function Login. - removed html_input
Code: [Select]
// LOGIN
function login() {
if (!_ADMIN) {
?>
<div class="adminpanel">
<h2><?php echo l('login'); ?></h2>
<form method="post" action="<?php echo _SITE?>administration/" id="post" accept-charset="<?php echo s('charset'); ?>">
<p>
<?php echo l('login_limit'); ?>
</p>
<p>
<label for="uname"><?php echo l('username'); ?></label>:
<br />
<input type="text" name="uname" id="uname" class="text" value="" />
</p>
<p>
<label for="pass"><?php echo l('password'); ?></label>:
<br />
<input type="password" name="pass" id="pass" class="text" value="" /></p>
<?php echo mathCaptcha(); ?>
<p>
<input type="hidden" name="Loginform" id="Loginform" value="True" />
<input type="submit" name="submit" id="submit" class="button" value="<?php echo l('login'); ?>" />
</p>
</form>
</div>
<?php
} else {
?>

<h2><?php echo l('logged_in'); ?></h2>
<p>
<a href="<?php echo _SITE?>logout/" title="<?php echo l('logout'); ?>"><?php echo l('logout'); ?></a>
</p>
<?php
}
}
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: Improve one function a week
« Reply #28 on: October 08, 2009, 02:42:27 PM »

Simple code refactoring
Code: [Select]
<?php
// DISPLAY PAGES
function pages() {
function pages_li($url$text) {
global $categorySEF;
$class = ($categorySEF == $url) ? ' class="current"''';
if (!empty($url)) $url .= '/';
echo '<li><a'.$class.' href="'._SITE.$url.'">'.$text.'</a></li>';
}
pages_li(''l('home'));
pages_li('archive'l('archive'));
$qwr = !_ADMIN ' AND visible=\'YES\'' '';
$query "SELECT id, seftitle, title FROM "._PRE.'articles'." WHERE position = 3 $qwr ORDER BY artorder ASC, id";
$result mysql_query($query);
while ($r mysql_fetch_array($result)) {
if ($r['id'] != s('display_page')) {
pages_li($r['seftitle'], $r['title']);
}
}
pages_li('contact'l('contact'));
pages_li('sitemap'l('sitemap'));
}
?>

Perfect example of code simplifying - although if it makes it into the core (as it should), can someone please move archive to below the query block? I might be picky, but I hate, erm, throughly dislike (hate is too strong for this), that archive comes before user-made pages. In my mind, user-made pages have greater importance than Archive. Or Site Map.
Logged

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: Improve one function a week
« Reply #29 on: October 08, 2009, 08:58:41 PM »

Perfect example of code simplifying - although if it makes it into the core (as it should), can someone please move archive to below the query block? I might be picky, but I hate, erm, throughly dislike (hate is too strong for this), that archive comes before user-made pages. In my mind, user-made pages have greater importance than Archive. Or Site Map.
Fred - I thought I fixed that here: http://snewscms.com/forum/index.php?topic=7996.0 I think that would solve that problem and some other problems noted frequently, but some people need to realize the current functionality hinders usability as you noted.
Logged
Pages: 1 [2] 3 4 ... 9