replaceing text

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
michael1991j
Forum Commoner
Posts: 37
Joined: Tue Jun 06, 2006 8:48 pm

replaceing text

Post by michael1991j »

hi i am building a bloging system. if you are famerial with blooger.com they have soomany blog templates. i was want to use some of them for my site
but i need atom feed and goes with cgi and all that and i dont want to do that. so i downloaded the blog and it had varible but they were atom base. i was wondering if anyone knows a solution that i could use php to replace that text or you could say varibles with a mysql query. is there like something like i haveing a php script and that would read from the template and ouput the blog template with my sql querys. another thing is that i dont want to change the template with php all over it or replace the varible.

thank you in advance 8O
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Why not use something like WordPress?
User avatar
michael1991j
Forum Commoner
Posts: 37
Joined: Tue Jun 06, 2006 8:48 pm

Post by michael1991j »

i like it but i am make a bloging hosting system sorry i meant that and not a single user
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

Post by SidewinderX »

perhaps str_replace( ) would work for this?
User avatar
michael1991j
Forum Commoner
Posts: 37
Joined: Tue Jun 06, 2006 8:48 pm

Post by michael1991j »

ok this will work but i have one problem i dont know to make it aim for the html text but it works with php texts
User avatar
michael1991j
Forum Commoner
Posts: 37
Joined: Tue Jun 06, 2006 8:48 pm

Post by michael1991j »

anyone
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

I might help out tomorrow. Need sleep nowwwwwwwwwwwwwwwwwwwwwwwwwww
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

michael1991j wrote:ok this will work but i have one problem i dont know to make it aim for the html text but it works with php texts
What do you mean by this? Are you trying to str_replace() HTML, like in a template?
User avatar
michael1991j
Forum Commoner
Posts: 37
Joined: Tue Jun 06, 2006 8:48 pm

Post by michael1991j »

ok let me refrase that i am wondering how would i specify my templete to str_replace i am a noob to this function

http://www.feedforall.com/download/rss2html.zip if you look at this script you would get a idea of what i am wanting to do but with one of those blogger.com templates repacing the text with a mysql query .
but the problem with this script i cant mod it. i tryed and i failed .so i am trying to make one from scratch


sorry for the spelling and grammer
Last edited by michael1991j on Thu Aug 10, 2006 10:22 pm, edited 1 time in total.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You're going to need a lot more than just str_replace(). Look into the file system functions: fopen(), fread(), fclose() and file().
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

This is a very badly titled topic. What you are trying to achieve has little to do with replacing text. What you need to do is simple.
  1. Go on to blogger and choose any blog to look at
  2. Alter your blogs HTML output to be as similar to bloggers as possible
  3. Then download the CSS and images from a blogger template you like and save them when you use them in your blog your blog will look like the template
  4. Repeat 3 for all the templates you want
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

That's probably not a bad idea. Another thing to contend with is knowing what all of the Blogger template vars actually do and how they do it.

You might be better off looking for a template parser applicaiton.
User avatar
michael1991j
Forum Commoner
Posts: 37
Joined: Tue Jun 06, 2006 8:48 pm

Post by michael1991j »

thank you oley :D 8O 8O !! i know that but thanks for reminding me about it .
ok what is this about the parfraser you were saying building this script willl give me a migrane 8O :!: :!:
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Basically, just like any envionment where a user theme can change, most apps use some form of template parsing application. WordPress uses one, phpBB uses one, Blogger uses one. How it works is that the app grabs a theme, the theme has a series of template vars in it, the app grabs those template vars and places the vars for actual content fetched by the app. Is that what you are looking to do?
User avatar
michael1991j
Forum Commoner
Posts: 37
Joined: Tue Jun 06, 2006 8:48 pm

Post by michael1991j »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


i look up paphasing with php on google it gave me a torurial that i could do  parafrasing i got it to work
 her it is  and i didnt need to use those insane functions

Code: Select all

<?php 

ob_start(); 

include('template.htm'); 

$pageHTML=addslashes(ob_get_contents()); 

ob_end_clean(); 


eval("\$pageHTML=\"$pageHTML\";"); 

 
$b = str_replace("world","Peter",$pageHTML);
$a = str_replace("song","somthing",$b);


echo $a; 


?>

and here is the htm it reads off

Code: Select all


<html> 

<head> 

<title>$title</title> 

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 

</head> 

<body> 

<div> 



<p> song  </p> 
hello world?

</div> 

</body> 

</html> 


this will work but the problem is when i do my comment and post i am in trouble because i dont know how to make a array with this code does anyone know


ps i put in the str_replace and not the tortial they just made so i can out put the html in php


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Post Reply