Membership is FREE, giving all registered users unlimited access to every Acorn Domains feature, resource, and tool! Optional membership upgrades unlock exclusive benefits like profile signatures with links, banner placements, appearances in the weekly newsletter, and much more - customized to your membership level!

page content query

Status
Not open for further replies.

Paullas

Staff member
Joined
Jul 13, 2004
Posts
5,817
Reaction score
361
im not sure if this is possible but....

is it possible to a certain keyword on a .php page that when is displayed pulls text from a file and inserts in onthe page.

also come to think of it, is this possible with an image also
hope that makes sence lol
 
Last edited:
Do you mean something like this?

<html><body>This is the text that is in the page but you want a <?php>$insert=file("input_file.txt"); echo $insert; ?> piece of text from the text file in the code to appear before this sentence and on any other pages to put the PHP code in?</body></html>

The above would pace the output of the file input_file.txt in any page it was used in, and if you change the file the text is changed on all pages that the php code is in. saying that there are lots of ways of doing the same thing.

Ty

im not sure if this is possible but....

is it possible to a certain keyword on a .php page that when is displayed pulls text from a file and inserts in onthe page.

also come to think of it, is this possible with an image also
hope that makes sence lol
 
not sure - original question is bit vague:-

Code:
$original_text = "blah blah keyword1 blah";

$keywords = array('keyword1'=>'filename1.txt','keyword2'=>'filename2.txt');
foreach($keywords as $kw=>$file)
{
  $original_text = str_replace($kw,file_get_contents($file),$original_text);
}
 
yes and no ty

as im more thinking about it i think it would be better if i can get it so it looks at the url then displays the text or .html/.php

so for example i have cars.co.uk (i wish) when someone visits that url the index page looks at url in question then as said above brings on the file associated with that url.
 
This is one way of doing it.

Code:
code snippet removed

but you could make the site names into an array and then call the text up by doing a lookup, rather than writing out every site. That's the basics though. Obviously the part that looks up the domain could also be separated out to tidy up the code. I use a lot of this sort of stuff on my sites to allow single template use across multiple sites.
 
Last edited:
couldnt get the above to work ty getting header already sent error at top of the page.
 
im not sure if this is possible but....

is it possible to a certain keyword on a .php page that when is displayed pulls text from a file and inserts in onthe page.

also come to think of it, is this possible with an image also
hope that makes sence lol

I am going to answer your general question in general terms, and that is, php is good for using keywords to retrieve data or files.

Rgds
 
I am going to answer your general question in general terms, and that is, php is good for using keywords to retrieve data or files.

Rgds

that helped me :) (not)
 
Yeah its possible. I do this using SQL for a quick and nasty way, so I slam page into SQL then use an index page that simply pulls the page out of no where.

I also do this with includes using a switch statement.

So you'd have

index.php
-cars.inc.php
-house.inc.php
-etc

Then use a switch based on the URL to include the right include :)
 
I scribbled this into notepad earlier, I'm pretty sure the syntax is right. This isn't the best way to do it, but its the easiest without a templating engine and stacks of SQL :)

PHP:
switch($dom . $ext) {
	case 'cars.co.uk':
		include('./cars.inc.php')
	break;

	case 'bikes.co.uk':
		include('./bikes.inc.php')
	break;
	
	default:
		include('./basic.inc.php')
	break;
}
 
cheers guys, im working on it a few ways so will reply if i suss what i want it to do
 
I was editing some code like this, and it thought maybe worth posting as it allows you some basic SEO all in one file.

PHP:
<?php 
switch($dom . $ext) {
	case 'cars.co.uk':
		$header = "";
		$title = "Cars.co.uk - Number 1 Source of Car Information";
		$keyword = "cars, convertibles, saloon, hatchback, hot hatch";
		$desc = "The premiere UK Source for Car Information Blah";
		$footer = "Copyright Cars.co.uk";
		// you can add any others here
		include('./cars.inc.php')		
	break;

	case 'bikes.co.uk':
		$header = "";
		$title = "Bikes.co.uk - Number 1 Source of Bike Information";
		$keyword = "bikes, rally, track, dirt, chopper";
		$desc = "The premiere UK Source for Bike Information Blah";
		$footer = "Copyright Bike.co.uk";
		include('./bikes.inc.php')
	break;
	
	default:
		include('./basic.inc.php')
	break;
}
?>

Then inside the cars.inc I use <?php echo $header; ?> that way I can customise them as I go all in once place, so its a very very messy, nasty and simple template system that does the job :)

You can use more includes within the includes but to try and keep it tidy name them like cars.filename.inc.php so all the cars are together :)

Hard to offer any other advice without knowing more about the project :)
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Premium Members

Latest Comments

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
      There are no messages in the current room.
      Top Bottom