Thread Verfasser: Homdax
Thread ID: 132
Thread Info
Es gibt 8 Beiträge zu diesem Thema, und es wurde 5229 Mal angesehen.
 Thema drucken
RSS View Help [English]
Homdax
I am sorry for the English, but I have a small problem that is preventing the further development of a site I have an absolute responsibility to get in good shape.

It is a site for a political organisation in Sweden and since we are having elections this year I have been asked to remake it. I have chosen PHP-Fusion because I really have little coding contacts outside of this little world of ours.

If you look at www.eslovsmoderaterna.se/eslovsmodera...aterna.php there is a panel with the following code:


echo "<div class='floatfix center' style='width: 99%; margin-left: 5%; margin-right: auto;'>\n";
echo "<div style='width:30%; float:left;margin:0 5px;'>\n";
openside("Nyheter");
$url = "http://www.moderat.se/feeds/news.xml";
$items = 5;
$xml = simplexml_load_file($url);

    for($i=0;$i<$items;$i++) {
        echo utf8_decode(" ".THEME_BULLET."  <a href='".$xml->channel->item[$i]->link."'>".$xml->channel->item[$i]->title." </a><br />");
    }

closeside();

echo "</div>\n<div style='width:30%; float:left; margin:0 5px;'>\n";

openside("Press");
   $url = "http://www.moderat.se/feeds/press.xml";
$items = 5;
$xml = simplexml_load_file($url);

    for($i=0;$i<$items;$i++) {
        echo utf8_decode(" ".THEME_BULLET."  <a href='".$xml->channel->item[$i]->link."'>".$xml->channel->item[$i]->title." </a><br />");
    }

closeside();

echo "</div>\n<div style='width:30%; float:left;'>\n";

openside("Politik");

$url = "http://www.moderat.se/feeds/politics.xml";
$items = 5;
$xml = simplexml_load_file($url);

    for($i=0;$i<$items;$i++) {
        echo utf8_decode(" ".THEME_BULLET."  <a href='".$xml->channel->item[$i]->link."'>".$xml->channel->item[$i]->title." </a><br />");
    }

closeside();

echo "</div>\n</div>\n";


Now, the RSS are not 100%, for instance there have been no updates of the one called "Press" category in a long time. But two of them work. The issue I am trying to sort out is how to make the rss feeds also pick the images from the generating site, which is www.moderat.se . If you look at the center page there are 3-4 squares with images and text that are being generated as feeds. The site is basically Drupal.

Would you perhaps know how I may be able to generate the same feeds (with them images) on "my" site in the code I posted above?

Any help much appreciated, I can get more info if needed, but this is what I have right now, which I have put together with Craig who helped me a lot with other parts of the site.
Bearbeitet von John Doe am 17. Januar 2014 17:45:02
Information:
PHP Version: Nicht ausgewählt •  MySQL Version: Nicht ausgewählt •  PHP-Fusion: Nicht ausgewählt
 
John Doe
Hello Richard, nice to see you :)

first of all I have to say that unfortunately very less people in here are speaking english, so they are not able to support in english language.

Basically you only can grab datas over XML that are provided by XML.
If datas of pictures are missing in XML-File, you don't have a chance to grab them there.

So I guess it would be a better idea to ask the people which are providing that feed.
Information:
PHP Version: Nicht ausgewählt •  MySQL Version: Nicht ausgewählt •  PHP-Fusion: Nicht ausgewählt
 
Homdax
I did. The feed is provided "as is". But I have also come to realize they use a javascript slider with custom images for the presentation and that is probably based on a Drupal specific plugin. So I really do not know how to even begin to approach this.

Much appreciated Layzee...;)

Zusammengefügt am 17. Januar 2014 um 11:40:39:
I got some help:

Zitat


[16-January-2014 11:08] Hien: done
[16-January-2014 11:08] Hien: i'll pass you the function
[16-January-2014 11:08] Hien:

 function fusion_photocopier($url, $items=5) { 
 
    $html = "";
    $xml = simplexml_load_file($url);
 
    $i = 0;
    for($i=0; $i<=$items; $i++) {
 
        $title = utf8_decode($xml->channel->item[$i]->title);
        $link = utf8_decode($xml->channel->item[$i]->link);
        $news = utf8_decode($xml->channel->item[$i]->description);
        $date = utf8_decode($xml->channel->item[$i]->pubDate);
 
        $html .= "<p><a href='$link' style='text-decoration:underline; font-weight:bold;'>$title</a><br/><span class='small'><strong>$date</strong></span></p>\n";
        $html .= "<p>$news</p>\n";
 
    }
 
    return $html;
}

[16-January-2014 11:09] Hien: get that first
[16-January-2014 11:09] Hien: ah wait. better I code you a panel.. lol
[16-January-2014 11:10] Hien: nvm.
[16-January-2014 11:10] Hien: that is the function
[16-January-2014 11:11] Hien: Just copy and paste it to anywhere underneath maincore.php or something.. before ?>
[16-January-2014 11:11] Hien: To use the function:
[16-January-2014 11:11] Hien:

$url = "http://www.moderat.se/feeds/news.xml"; 
echo fusion_photocopier($url, 5);

[16-January-2014 11:11] Hien: 5 is the news count
[16-January-2014 11:12] Ainz: got that
[16-January-2014 11:12] Hien: try
[16-January-2014 11:12] Hien: Craig is right in the certain portion.
[16-January-2014 11:12] Hien: The Pic is embedded together with the news
[16-January-2014 11:12] Hien: To access and grab the pic out, you need to use DOM Parser.
[16-January-2014 11:13] Hien: Google for PHP Dom Parser. Ask Craig to read and implement for you.
[16-January-2014 11:13] Hien: It's just a walk in a park for him.
[16-January-2014 11:13] Ainz: ok, I got that, pasting it into a CP
[16-January-2014 11:14] Ainz: omg
[16-January-2014 11:14] Hien: The function cannot be in a panel ok. It will get fatal error.
[16-January-2014 11:14] Hien: ok :)
[16-January-2014 11:14] Hien: Can?
[16-January-2014 11:14] Ainz: http://www.eslovsmoderaterna.se/viewpage.php?page_id=13
[16-January-2014 11:14] Hien: Ok done
[16-January-2014 11:14] Hien: :)
[16-January-2014 11:15] Ainz: some styling and shit and the dom parser
[16-January-2014 11:15] Hien: Yep.
[16-January-2014 11:16] Hien: This is the parser: http://simplehtmldom.sourceforge.net/manual.htm
[16-January-2014 11:16] Hien: Download, install properely
[16-January-2014 11:16] Ainz: Il get back to you on the stuff we sort out and if it is enough... Got people on my back looking for a "look" and they just see how it can look and I try to sort out what can "work".
[16-January-2014 11:16] Hien: Ask Craig help you on the install. You need to require_once "path_to_parser";
[16-January-2014 11:16] Hien: in maincore.php
Then accessing the image can be done. Ask him to read the manual on the links I sent you.


// Find all element which id=foo 
$ret = $html->find('#foo');
 
// Find all element which class=foo
$ret = $html->find('.foo');
 
// Find all element has attribute id
$ret = $html->find('*[id]');
 
// Find all anchors and images
$ret = $html->find('a, img');


[16-January-2014 11:17] Hien: The parser can select anything and return the object as $ret
[16-January-2014 11:17] Hien: or any string
[16-January-2014 11:17] Hien: very powerful tool


From there you can add trimtext as below


[16-January-2014  15:05] Hien: pass this function to Craig
[16-January-2014  15:05] Hien: function trim_text($str, $length=false) {
    $length = (isset($length) && (!empty($length))) ? stripinput($length) : "300";
 
    $startfrom= $length;
    for($i=$startfrom; $i<=strlen($str); $i++)
    {
        $spacetest=substr("$str", $i, 1);
        if($spacetest==" ")
        {
            $spaceok=substr("$str", 0, $i);
            return ($spaceok."...");
            break;
        }
    }
    return($str);
}
[16-January-2014  15:05] Hien: I built it.


$str = the whole string which have the whole chunk of text.
$length = any number you want.

I hope someone else may have use for this. ;)
Bearbeitet von Homdax am 17. Januar 2014 10:40:39
Information:
PHP Version: Nicht ausgewählt •  MySQL Version: Nicht ausgewählt •  PHP-Fusion: Nicht ausgewählt
 
Rolly8-HL
Deutsche Seite deutsche Fragen deutsche Antworten , wenn ich mich auf eine englische Seite begebe dort auf deutsch Fragen stelle bekomme ich zu Antwort Fragen & Antworten bitte nur auf englisch (nicht ein mal zweisprachig).

Ich habe nichts gegen Internationale User auch nicht wenn die Frage zweisprachig gestellt wird, (Chrome übersetzt) sollte da schon reichen wenn die Frage sinnvoll gestellt wurde anders kann ich das auch nicht machen da ich kein englisch spreche.

Antworten auf deutsch sollten hier den vor rang haben, wer es auch noch auf englisch beantwortet ist eine nette Geste.
Gruß Rolly8-HL
Was für Andere Wichtig ist muss für mich nicht genauso Wichtig sein!
Bin Dickkopf Unbelehrbar mache aus Protest nicht das was andere für Richtig halten!
Das gibt einem zu Denken oder?
Information:
PHP Version: Nicht ausgewählt •  MySQL Version: Nicht ausgewählt •  PHP-Fusion: Nicht ausgewählt
 
John Doe
@ Rolly: Klar, dass das hier eine deutsche NSS ist. Jedoch sollte man die von Dir eh beschriebene Funktion dann nutzen wenn man im Zeitalter wo Englisch normal geworden ist, dann von alleine den Übersetzer benutzen auch ohne zusätzliche Hinweise.

Oder was möchtest du mit deinem Post bezwecken?
Falls du angst hast, dass wir hier nur noch Englisch schreiben, keine Sorge, wir bleiben schon bei der Sprache Deutsch im Primaeren.
Dieses Mitglied wurde gelöscht!
Information:
PHP Version: Nicht ausgewählt •  MySQL Version: Nicht ausgewählt •  PHP-Fusion: Nicht ausgewählt
 
Homdax
Google Translate:
Ich verstehe Rolly. Er hat einen gültigen Punkt. Ich meine nicht respektlos, aber diese Gemeinschaft ist auch in der Spitze der PHP-Fusion-Nutzung und Entwicklung, und ich möchte glauben, wir haben gegenseitigen Respekt für einander.
Information:
PHP Version: Nicht ausgewählt •  MySQL Version: Nicht ausgewählt •  PHP-Fusion: Nicht ausgewählt
 
Dat Tunes
Englisch ist eine weltweite an erkannte Sprache, die wir ggf. auch hier pflegen werden.
Jeder von uns benutzt jeden Tag Englisch, gewollt oder ungewollt und hier auf der Seite ist auch schon im Logo Englischer Text zu finden, was aber nicht heisst, das wir nur Englisch hier sprechen. Jeden Benutzer ist es frei überlassen, ob er mit einen Übersetzungstool schreibt oder rein im Englisch. Bei den Antworten wäre es dann aber immer wieder Hilfreich, wenn man dann 2 Sprachig antwortet.

Jetzt aber wieder zum Problem von Ainz zurück, darüber kann man in einen anderen Forumbereich gerne reden.

----

English is a global language to recognize that we are possibly also maintain here.
Each of us uses every day English, intentionally or unintentionally, and here on the page is already available on the Logo English text, which does not mean that we only speak English here. Every user is left free to decide whether he writes with a translation tool or purely in English. With the responses but it would then always helpful when you then answers two languages​​.

But now back to the problem of Ainz back, you can talk about it in another forum area like.
Das Problem ist nicht das Problem, das Problem ist der Nutzer, der das Problem verursacht.
Was lernen wir ?
Wir entfernen einfach den Nutzer und das Problem ist gelöst !

Sollte das Problem nicht gelöst sein, WD40! WD40 hilft immer !
Information:
PHP Version: Nicht ausgewählt •  MySQL Version: Nicht ausgewählt •  PHP-Fusion: Nicht ausgewählt
 
Rolly8-HL
@Ainz

Danke für Dein Verständnis.

Google Translate:
Thank you for your understanding.
Gruß Rolly8-HL
Was für Andere Wichtig ist muss für mich nicht genauso Wichtig sein!
Bin Dickkopf Unbelehrbar mache aus Protest nicht das was andere für Richtig halten!
Das gibt einem zu Denken oder?
Information:
PHP Version: Nicht ausgewählt •  MySQL Version: Nicht ausgewählt •  PHP-Fusion: Nicht ausgewählt
 
Springe ins Forum: