PDA

View Full Version : Moving the News to another URL


Bundy
20th of September 2004 (Mon), 00:00
Pekka,

It's been a while since I last posted. Hello and thanks again for all of your past support.

I have been trying to move the News to another page that isn't within the EE site. Is it possible to move? If so, can you give any suggestions about how to do it?

My goal is to have the News show up on the inndex page of our main site.

vancouverimageworks.com and imageworksgallery.com are both at the same directory level but in different directories if it helps.
public_html/imageworks
public_html/imageworksgallery

Thanks,

Bundy

Pekka
21st of September 2004 (Tue), 12:17
This would need some code to

- connect to database 1
- read news and add to array X
- connect to database 2
- read news and add to array X
- sort array X by date
- output data to html

The news read code is in indexstyles/building_blocks.php as function "ee_news". If you know any PHP writer it is quite straightforward to code the above scheme with that, just do the array in while loop e.g


function get_ee_news_from_database ($lang,$server,$user,$pass,$database, $last) {

global $cumulative_news;

$conn = @mysql_connect($server, $user, $pass);
if (!@mysql_select_db($database)) {

$getnews = mysql_query(
"
SELECT
ee_news.ee_news_id,
ee_news_{$lang}.ee_news_header,
ee_news_{$lang}.ee_news_text,
ee_news.ee_news_date,
ee_news.ee_news_time,
ee_news.ee_news_datetime,
ee_news.ee_news_for_www
FROM
ee_news_{$lang},
ee_news
WHERE
ee_news.ee_news_id = ee_news_{$lang}.ee_news_id
AND ee_news.ee_news_for_www = 'yes'
ORDER by
ee_news_datetime DESC
LIMIT $last
"
);
if (!$getnews) {
print mysql_error();
exit();
}

while ($cnn = mysql_fetch_array($getnews)) {
$cumulative_news[] = array(
"id" => $cnn["ee_news_id"],
"header" => $cnn["ee_news_header"],
"datetime" => $cnn["ee_news_datetime"]
}

mysql_close();
return;
}
}


.... which you would run in php like

get_ee_news_from_database ("eng","localhost","joe","joepass","ee_database_1", "5")
get_ee_news_from_database ("eng","localhost","will","willpass","ee_database_2", "7")

... whichs brings you array "$cumulative_news" for sorting and printing purposes. To refine above it could be made as a snippet but I would not do that because of security (passes in calling code!).

PS. I have not tested above but it should work....

Bundy
23rd of September 2004 (Thu), 13:35
Pekka,

I haven't had a chance to try the code out yet, but can you clarify a few things before I start pulling my hair out. I'm getting much better at PHP, but when it comes to accessing a database, I'm still a little unsure.

Would the function get_ee_news_from_database still be located in the building_blocks.php or would it be placed in the new page along with the get_ee_news_from_database ("eng","localhost","joe","joepass","ee_database_1", "5")?

Do I need to include any of the following code or is it replace by the get_ee_news_from_database ("eng","localhost","joe","joepass","ee_database_1", "5")?

include ("toroot.php");
include ($toroot . "add/connect.php");
include ($toroot . "language.php");
include ($toroot . "slashwork.php");


Thanks

Bundy

Pekka
23rd of September 2004 (Thu), 15:26
Pekka,

I haven't had a chance to try the code out yet, but can you clarify a few things before I start pulling my hair out. I'm getting much better at PHP, but when it comes to accessing a database, I'm still a little unsure.

Would the function get_ee_news_from_database still be located in the building_blocks.php or would it be placed in the new page along with the get_ee_news_from_database ("eng","localhost","joe","joepass","ee_database_1", "5")?

You must have the function there (once) and then you call it as many times you need. It is independent of EE, so answer to

Do I need to include any of the following code or is it replace by the get_ee_news_from_database ("eng","localhost","joe","joepass","ee_database_1", "5")?

include ("toroot.php");
include ($toroot . "add/connect.php");
include ($toroot . "language.php");
include ($toroot . "slashwork.php");

is no. You are supposed to write the actual output code for a non-EE page so EE's language, style and other features are not used. Of course you could use e.g. language code from EE, but perhaps that is not neccessary?