Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 05:55:40 PM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155545 Posts in 21714 Topics by 7736 Members
Latest Member: chris85
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: news 3.5 directory (or rewrite method ?)  (Read 474 times)
YoJoe

Offline Offline

Posts: 74


WWW
« on: May 18, 2011, 03:19:17 PM »

Howdy
I'm using shorturl hack to rewrite pages links, but I haven't succeed to make it work also with news, so I'm trying to save news on root/news directory instead of root/pages/posts

By changing paths in lines 123 and 125 of save_post (news module) to
Code:
WB_PATH.'/news/'
news are being saved in the directory I want, but what else do I have to change to get "read more" links pointing to: address/news/test-news-11.php
instead of:  address/pages/posts/test-news-11.php ?

I wouldn't want to save pages on root (by removing pages directory in WB settings), and rewrite topics found across the forum doesn't come up with anything useful (they do not even work with normal pages) for wb 2.8.2.1449

Do you have any ideas ?
Logged

WuJitsu - in web I trust  cool
pcwacht
AddOn Development
*
Offline Offline

Posts: 2858



WWW
« Reply #1 on: May 18, 2011, 03:45:33 PM »

check save_post.php, and check save_post.php for PAGES_DIRECTORY

That should do it, I think


Though I would have changed the urlrewrite to match the news system.
Otherwise I'll keep on editing files everytime an update is there


John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
YoJoe

Offline Offline

Posts: 74


WWW
« Reply #2 on: May 18, 2011, 04:20:20 PM »

check save_post.php, and check save_post.php for PAGES_DIRECTORY

That should do it, I think


Though I would have changed the urlrewrite to match the news system.
Otherwise I'll keep on editing files everytime an update is there

I'm sorry but I don't follow Sad
The only save_post.php file is located in modules/news.
Regardless of that I can't find out where should I look and what should I change to get links pointing to root/news/newsID.php.
There's
Code:
// Work-out what the link should be
$post_link = '/posts/'.page_filename($title).PAGE_SPACER.$post_id;
in save_post.php but it seems that it uses by default WB_PATH.PAGES_DIREC TORY before '/posts' and I don't know how can I overwrite it - assuming it would be the solution I am looking for.

From the other hand because I'd have to get rid of pages directory at all, and since this hack works fine for pages ( http://short.allwww.nl/ )I want to leave pages structure as it is.
I've been trying to modificate this hack to get links also from mod_news_posts table, but my programming skills are near to zero, and from what I can deduct
Code:
$linkstart = WB_URL.PAGES_DIRECTORY;
in droplet's code doesn't take /pages/posts into consideration.
Logged

WuJitsu - in web I trust  cool
pcwacht
AddOn Development
*
Offline Offline

Posts: 2858



WWW
« Reply #3 on: May 18, 2011, 06:59:28 PM »

the link for the newsitem is stored in the database
it is constructed by save_post.php
the link is without the /pages/ part

thus, to recreate a working link
the link is pasted to wburl + pagespart + linkpart

Code:
$post_link = '/posts/'.page_filename($title).PAGE_SPACER.$post_id;
here the link is created, the /posts/ can be changed to suit your needs

Code:
$linkstart = WB_URL.PAGES_DIRECTORY;
here the beginning part is created (from wich the link from the database is pasted)
if you change this to:
Code:
$linkstart = WB_URL;
the /pages/ bit will be lost

hope this explains more?

to get you started, here is the changed part of save_post.php wich you're after
Code:
// Include WB functions file
require(WB_PATH.'/framework/functions.php');

// Work-out what the link should be
$post_link = '/news/'.page_filename($title).PAGE_SPACER.$post_id;

// Make sure the post link is set and exists
// Make news post access files dir
make_dir(WB_PATH.'/news/');    // removed .PAGES_DIRECTORY changed /posts/ to /news/
$file_create_time = '';
if(!is_writable(WB_PATH.'/news/'))   // same as above
{
$admin->print_error($MESSAGE['PAGES']['CANNOT_CREATE_ACCESS_FILE']);
}
elseif(($old_link != $post_link) OR !file_exists(WB_PATH.$post_link.PAGE_EXTENSION))   // removed PAGES_DIRECTORY.
{
// We need to create a new file
// First, delete old file if it exists
if(file_exists(WB_PATH.$old_link.PAGE_EXTENSION))  // same as above
    {
        $file_create_time = filemtime($old_link.PAGE_EXTENSION);
unlink(WB_PATH.$old_link.PAGE_EXTENSION);  // same as above
}

    // Specify the filename
    $filename = WB_PATH.'/'.$post_link.PAGE_EXTENSION;  // same as above
    create_file($filename, $file_create_time);
}
this changes all the links to
/pages/posts/ to /news/
and checks to see if /news/ exists

have fun,
John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!