Każdy temat założony w ewidentnie złym dziale będzie usuwany! Proszę czytać opisy działów i regulamin!
Wszystkie tematy są moderowane. Przed ukazaniem się muszą być zaakceptowane przez Redakcję. Prosimy nie wysyłać wielokrotnie tego samego wpisu.
![]() ![]() |
30.4.2008 - 19:03
Post
#1
|
|
|
aktywność: ![]() Grupa: Bloger Postów: 5 Nr: 4 059 |
Witam! Co prawda, byłem tu na forum, ale robiliście chyba po tym czystkę kont
Mam zamiar postawić bloga (adresem chyba będzie blog.xmodules.wytry.net). Ale robię samą stronę internetową (opartą na XModules - chyba adresem będzie xmodules.wytry.net) i forum (IPB 2.3.4 - chyba adresem będzie xmodules.wytry.net). Lecz został mi na stronie blok (i do tego nie wiem jak go usunąć), gdzie chciałbym umieścić najnowszy wpis z bloga (funkcja skroc($tekst, $ilość_znaków) skraca tekst do iluśtam znaków). I teraz pytanie: jak wyświetlić ostatni wpis (w sensie najnowszy) w takim bloku? Myślałem nad "Pobieranie kanału RSS -> odczytywanie", ale RSS nie jest za bardzo przyjazny dla SimpleXML czy jak tam temu modułowi. Jak to zrobić? Pzdr. Piotr1 / pzduniak. |
|
|
|
30.4.2008 - 19:47
Post
#2
|
|
![]() aktywność: ![]() ![]() ![]() ![]() ![]() Grupa: +Bloger Postów: 301 Nr: 3 158 |
Hmm... metoda następująca:
KOD <?php require_once('sciezka/do/wp-blog-header.php'); ?> Plik ten ładuje klasy, funkcje i inne bajery związane z wordpressem - do tego zdała by się integracja (include) pliku konfiguracyjnego wp-config.php, a potem wstawienie do bloku na stronie odowiedniego loopa. Choć to tylko teoria... -------------------- |
|
|
|
01.5.2008 - 12:13
Post
#3
|
|
|
aktywność: ![]() Grupa: Bloger Postów: 5 Nr: 4 059 |
No tak... akurat nie chciałbym takiego sposobu, ponieważ chyba łatwiej przez RSS'a
Ale dobra... teraz nie wiem, dlaczego jak wpisuję do skryptu poniżej adres http://localhost/blog/wp-rss.php , to pokazuje mi się błąd, że nie można załadować pliku -.- CODE <? // define the namespaces that we are interested in $ns = array ( 'content' => "http://purl.org/rss/1.0/modules/content/", 'wfw' => "http://wellformedweb.org/CommentAPI/", 'dc' => "http://purl.org/dc/elements/1.1/" ); // obtain the articles in the feeds, and construct an array of articles $articles = array(); // step 1: get the feed $blog_url = "http://localhost/integration/blog-rss.php"; $rawFeed = file_get_contents($blog_url); $xml = new SimpleXmlElement($rawFeed); // step 2: extract the channel metadata $channel = array(); $channel["title"] = $xml->channel->title; $channel["link"] = $xml->channel->link; $channel["description"] = $xml->channel->description; $channel["pubDate"] = $xml->pubDate; $channel["timestamp"] = strtotime($xml->pubDate); $channel["generator"] = $xml->generator; $channel["language"] = $xml->language; // step 3: extract the articles foreach ($xml->channel->item as $item) { $article = array(); $article["channel"] = $blog; $article["title"] = $item->title; $article["link"] = $item->link; $article["comments"] = $item->comments; $article["pubDate"] = $item->pubDate; $article["timestamp"] = strtotime($item->pubDate); $article["description"] = (string) trim($item->description); $article["isPermaLink"] = $item->guid[?isPermaLink?]; // get data held in namespaces $content = $item->children($ns["content"]); $dc = $item->children($ns["dc"]); $wfw = $item->children($ns["wfw"]); $article["creator"] = (string) $dc->creator; foreach ($dc->subject as $subject) $article["subject"][] = (string)$subject; $article["content"] = (string)trim($content->encoded); $article["commentRss"] = $wfw->commentRss; // add this article to the list $articles[$article["timestamp"]] = $article; print_r($articles); } // at this point, $channel contains all the metadata about the RSS feed, // and $articles contains an array of articles for us to repurpose ?> Edit: to wy tu macie codeboxy? Myślałem że macie jakąś starą tą wersję IPB Ten post edytował Piotr1 01.5.2008 - 16:15 |
|
|
|
01.5.2008 - 17:37
Post
#4
|
|
|
aktywność: ![]() Grupa: Bloger Postów: 5 Nr: 4 059 |
Rozwiązanie:
Prosty kod: CODE <? define('WP_USE_THEMES', false); require('../blog/wp-blog-header.php'); query_posts('showposts=1'); // ile postów wyświetlić if (have_posts()) : while (have_posts()) : the_post(); ?> <span class="data"> <?php the_time('d/m') ?> </span> <a href="<?php the_permalink() ?>"> <?php the_title();?> </a><br /><? the_content() ?><br /> <?php endwhile; endif; ?> Źródło: Dysk |
|
|
|
![]() ![]() |
| Wersja Lo-Fi | Aktualny czas: 29 08 08 - 19:25 |