1
equinox
Display only a part (#anchor) from a page with "file_get_contents" in another Page
  • 2010/2/14 15:13

  • equinox

  • Just popping in

  • Posts: 13

  • Since: 2010/1/17


Hi Guys,

i´ve readed that if i want to display only an fragment (anchor) from another page i can use it like this:

<?php 
$desc 
file_get_contents("http://www.mydomain.com/folder/file.html?#fragment2"); 
echo 
$desc;
?>


The code from the file.html looks like this:

<table id="fragmented">
<
tr>
<
td id="fragment1">The page title</td>
</
tr>
<
tr>
<
td id="fragment2">The code to display in another page</td>
</
tr>
<
tr>
<
td id="fragment3">The page footer</td>
</
tr>
</
table>


But thats not work correctly, the complete file is displayed and not only the anchor. What i do wrong?
I can not use some XOOPS Vars because that all is not in a module. I think, i do wrong anything with the php-code.

Greetings from Germany
Thom

2
equinox
Re: Display only a part (#anchor) from a page with "file_get_contents" in another Page
  • 2010/2/17 23:12

  • equinox

  • Just popping in

  • Posts: 13

  • Since: 2010/1/17


Hi at all,

I am Sorry! its sure that the complete file is displayed at the place where i would display it. (The anchor is just a place to display in a file, not only a part what i would to display.)

With "file_get_contents("");" is loaded a complete file into a String. How can i now this function extend to read only a part of this loaded file? I know i can set some extra (example: NULL, NULL, 10, 20) from start and/or until the end to read the file. But the size of my pages at this line is different long.
I can´t find anything about this.

Can anybody help me pls?

Greetings

3
equinox
Re: Display only a part (#anchor) from a page with "file_get_contents" in another Page
  • 2010/2/19 12:01

  • equinox

  • Just popping in

  • Posts: 13

  • Since: 2010/1/17


no one knows what i mean?

4
ghia
Re: Display only a part (#anchor) from a page with "file_get_contents" in another Page
  • 2010/2/19 13:02

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


The code for file.php has to include an anchor this is a <a href=... tag.
You can use the name (behind the #) to locate the starting place (= the anchor), but it is not so easy to determine the end of the section in question.

Are these pages for the extracts from your site or from a third party?

5
equinox
Re: Display only a part (#anchor) from a page with "file_get_contents" in another Page
  • 2010/2/19 13:36

  • equinox

  • Just popping in

  • Posts: 13

  • Since: 2010/1/17


Hi ghia and thank you very much for your answer.

I GOT IT!

I still meaned:
<table id="ajax">
 <
tr>
  <
td class="title" colspan="2">TITLE</td>
 </
tr>
 <
tr>
  <
td id="desc">here the content i would to display as only from this page</td>
  <
td id="thumb"><img... /></td>
 </
tr>
</
table>


To solve this issue is just in the page where this part is included:
<?php
$filepart 
"http://example.com/folder/filename.php"
$array file($filepart);
echo 
$array[5];
?>

That will happend only the 6th line is displayed.
BTW: a table-structure is a bad example for, because the table > tr > < /tr < /table must displayed too. I have the arrays just extended. But all works fine.

Greetings
Tom

Login

Who's Online

144 user(s) are online (79 user(s) are browsing Support Forums)


Members: 0


Guests: 144


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits