I want to display news from anoter web page onto mine, and I cannot figure out the best method for this.
The news on the other web page are displayed within a div class like the following
<div class="news-container">
<div class="news-list"><img src="abcd.jpg" /><strong>abcd</strong>
<p>What you see is what you get. <span class="morelink">Read more</span></p>
<div class="clear-both"></div>
</div>
<div class="news-list"><img src="efgh.jpg" /><strong>efgh</strong>
<p>What you see is what you get. <span class="morelink">Read more</span></p>
<div class="clear-both"></div>
</div>
<div class="news-list"><img src="ijkl.jpg" /><strong>ijkl</strong>
<p>What you see is what you get. <span class="morelink">Read more</span></p>
<div class="clear-both"></div>
</div>
<div class="news-list"><img src="mnop.jpg" /><strong>mnop</strong>
<p>What you see is what you get. <span class="morelink">Read more</span></p>
<div class="clear-both"></div>
</div>
I would like to be able to circle through the news and display them on my own page and rearranged according to our own site layout.
<div class="other-news">
<div class="news-list"><strong>abcd</strong>
<p>What you see is what you get. <img src="abcd.jpg" /></p>
</div>
<div class="news-list"><strong>efgh</strong>
<p>What you see is what you get. <img src="efgh.jpg" /> </p>
</div>
<div class="news-list"><strong>ijkl</strong>
<p>What you see is what you get. <img src="ijkl.jpg" /> </p>
</div>
<div class="news-list"><strong>mnop</strong>
<p>What you see is what you get. <img src="mnop.jpg" /> </p>
</div>
All suggestions are more than welcome.
// Nyborg
You need to look at PHP cURL or file_get_contents(security issues) or look at PHP HTML DOM Parser.
Also look at the legality of what your doing? (they normally provide an API if they want to let you have content)
Related
I've created a simple extbase/fluid based news extension with a listview showing the latest news. I'm also using indexed_search to search the whole website. The problem is, that the indexed_search not indexing any words of my news.
How can I use indexed_search for my own extension?
I can't find anything helpful on the web for hours. I would be very thankful for every hint or keyword.
Fluid template of the listview of my extension:
<f:for each="{berichts}" as="bericht">
<div class="bericht">
<div class="bericht_titel">
<h1>
<b>[<f:for each="{bericht.kategorien}" as="kategorie" iteration="i">{kategorie.name}<f:if condition="{i.isLast}"><f:then></f:then><f:else>, </f:else></f:if></f:for>]</b> <f:link.action action="show" pageUid="65" format="html" arguments="{bericht: bericht}">{bericht.titel}</f:link.action>
</h1>
<span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span></div>
<div class="bericht_text">
<f:if condition="{bericht.bild}">
<f:image image="{bericht.bild}" alt="" />
</f:if>
<f:format.html>{bericht.text}</f:format.html>
<div class="clearfix"></div>
<f:if condition="{bericht.anhaenge}">
<div class="bericht_anhang">
<b>Anhänge:</b><br />
<f:for each="{bericht.anhaenge}" as="anhang">
<div>
<a href="{anhang.originalResource.publicUrl}" target="_blank">
<f:if condition="{anhang.originalResource.title}">
<f:then>
{anhang.originalResource.title}
</f:then>
<f:else>
{anhang.originalResource.originalFile.name}
</f:else>
</f:if>
</a>
</div>
</f:for>
</div>
</f:if>
</div>
</div>
</f:for>
Generated HTML of one "Bericht"
<div class="bericht">
<div class="bericht_titel">
<h1><b>[Allgemeines]</b> Test</h1><span class="glyphicon glyphicon-menu-right" aria-hidden="true" style="transform: rotate(90deg);"></span>
</div>
<div class="bericht_text" style="display: block;">
<p>Dies ist ein Test</p>
<div class="clearfix"></div>
</div>
</div>
Now it's working. There was something incorrect with the page itself, but disable cache wasn't active. So if someone else has the same problem; try inserting the plugin to another page and test it. I had to delete the page and create it again.
I've used cycle2 a number of times, but am trying to do something a little different with HTML than what I normally would do. Please see my code below. Am I doing the right thing with the "data-cycle-slides" value?
<div class="cycle-slideshow"
data-cycle-fx="scrollHorz"
data-cycle-speed="700"
data-cycle-timeout="3600"
data-cycle-slides="> section > div.is-left">
<section id="is-top">
<?php foreach ($array as $key => $value) { ?>
<div class="is-left ic">
<div class="in">
<!-- more html -->
</div>
</div>
<?php } ?>
<div id="other-stuff">
<p>yo!</p>
</div>
<div id="more-stuff">
<p>hey!</p>
</div>
</section>
</div>
It looks ok to me, and when I view the page source, nothing seems amiss. But when I have a look in Firebug or the Firefox developer tools, things appear to be out of order. If there are two items in the array, I see something like this...
<div class="cycle-slideshow" data-cycle-fx="scrollHorz" <!-- et cetera -- >>
<div class="is-left ic">
<div class="in">
<!-- more html -->
</div>
</div>
<section id="is-top">
<div id="other-stuff">
<p>yo!</p>
</div>
<div id="more-stuff">
<p>hey!</p>
</div>
</section>
<div class="is-left ic">
<div class="in">
<!-- more html -->
</div>
</div>
<div class="is-left ic">
<div class="in">
<!-- more html -->
</div>
</div>
</div>
Note that items that should appear inside of #is-top are appearing outside of that section. Also, there are somehow three .is-left items in firebug, when there should be two.
I don't know if this is a case where firebug is making a mistake and causing me some confusion, or if I'm taking the wrong approach with cycle2.
I have created a single page Webapp using Bootstrap 3. It looks and feels like the standard IOS contacts app. I am using it for personal data on contacts. The contacts are in a sql table which I am querying. I am trying to pass a the PHP mySql id result to an internal #details id element.
The link is:
name
The div is:
<article id="details">
<div class="container-fluid">
<?php
$therecord = $_GET['page'];
$result = $Con ->query("SELECT * FROM `myTable` WHERE `id` = '$therecord'");
$details_row = $result->fetch_array(MYSQLI_BOTH);
?>
<div class="row">
<a href="#on_duty"><div class="col-xs-1"><span class="glyphicon glyphicon-menu-left floatleft apple_back_chevron appleBlue" aria-hidden="true"></span></div>
<div class="col-xs-6"><p class="apple_back_text appleBlue">On Duty Coordinators</p></div></a>
<a href="#edit_coordinators?page=<?php echo $details_row['id'] ;?>"><div class="col-xs-4"><p class="apple_forward_text appleBlue floatright">Edit</p></div>
<div class="col-xs-1"><p class="glyphicon glyphicon-menu-right floatright apple_forward_chevron appleBlue" aria-hidden="true"></p></div></a>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-xs-3">
<img class="img-circle" src="" alt="photo">
</div>
<div class="col-xs-9">
<h2><?php echo $details_row['name'];?></h2>
</div>
</div>
<div class="row">
<div class="apple_list appleGray">
<div class="col-xs-8">
<p class="appleBlue">station</p>
<p class="appleDGray"><?php echo $details_row['station']; ?></p>
</div>
<div class="col-xs-4">
</div>
</div>
</div>
<div class="row">
<div class="apple_list appleGray">
<div class="col-xs-8">
<p class="appleBlue">mobile</p>
<p class="appleDGray"><?php echo $details_row['mobile']; ?></p>
</div>
<div class="col-xs-2"> <img class="img-responsive apple_Glyph" src="_images/sms.png"></div>
<div class="col-xs-2"> <img class="img-responsive apple_Glyph" src="_images/phone.png"></div>
</div>
</div>
</div> <!-- /container -->
</article>
How do I pass a PHP "?page=$recordNo" internally? The page id is being passed, but not getting picked up by the next PHP
Try:
name
It is also very possible you could write it like so:
name
Basically, ? starts the query string and (if included) is always before the page anchor (fragment) # in a URI. See Uniform Resource Identifier for more info.
You can't do this:
name
Because there's an "hashtag", so it's interpreted by the browser as an in-page navigation, and the request isn't sent to the server, unless you catch it with javascript and then perform some ajax request...
This problem seems completely unrelated to PHP or MySQL.
Just look at the generated mark-up, which will look like this (re-indented to improve readability):
<a href="#edit_coordinators?page=333">
<div class="col-xs-4">
<p class="apple_forward_text appleBlue floatright">Edit</p>
</div>
<div class="col-xs-1">
<p class="glyphicon glyphicon-menu-right floatright apple_forward_chevron appleBlue" aria-hidden="true"></p>
</div>
</a>
There're two obvious issues:
The <a> tag is an inline element. It cannot have a whole bunch of block elements inside.
You inject the page GET parameter in the hash part of the URL, which is client-side only and is never sent to the server. It should be ?page=333#edit_coordinators
Said that, I admit I can't fully understand what you have in mind but it you really have a single-page application it has to be coded in JavaScript and possibly use AJAX. With just server-side technologies you can only
build a conventional web application.
I've been trying for a couple of hours and can't get my XPath to select the right text. Here's the structure:
<!-- (some divs that don't need to be selected) -->
<div class="main">
<div>
<div>
<div class="select">
<div class="child">
<div class="divwithtext">
</div>
</div>
<div class="child">
<div class="divwithtext">
</div>
</div>
<div class="child">
<div class="divwithtext">
</div>
</div>
<div class="dontselect">
<div class="divwithtext">
</div>
</div>
<div/>
</div>
</div>
</div>
Basically I want to select all the children of class="select" which is a child of class="main", but I don't need the text of class="dontselect".
Note: I am using XPath 1.0 due to php DOMXPath only supporting 1.0.
Edit:
Problem was my PHP code not returning all results that XPath gave me.
One possible way :
//div[#class='main']//div[#class='select']/div[not(#class='dontselect')]
I have code for filtration. But the data which filtered was static data. Now I want that data comes from database. Here I shown code snippet for that.
here is the script:
<script>
$('document').ready(function(){
$('#demo').jplist({
itemsBox: '.list'
,itemPath: '.list-item'
,panelPath: '.jplist-panel'
});
});
</script>
and this is the html design:
<div
class="jplist-group"
data-control-type="checkbox-group-filter"
data-control-action="filter"
data-control-name="themes">
<input
data-path=".architecture"
id="architecture"
type="checkbox"
/>
<label for="architecture">Architecture</label>
<input
data-path=".christmas"
id="christmas"
type="checkbox"
/>
<label for="christmas">Christmas</label>
</div>
<!-- item 1 -->
<div class="list-item box">
<!-- img -->
<div class="img left">
<img src="img/thumbs/arch-2.jpg" alt="" title=""/>
</div>
<!-- data -->
<div class="block right">
<p class="date">03/18/2012</p>
<p class="title">Architecture</p>
<p class="desc">Architecture is both the process and product of planning, designing and construction. Architectural works, in the material form of buildings, are often perceived as cultural symbols and as works of art. Historical civilizations are often identified with their surviving architectural achievements.</p>
<p class="like">25 Likes</p>
<p class="theme">
<span class="architecture">Architecture</span>,
<span class="brown">Brown</span>
</p>
</div>
</div>
Thanks in advance.