Any PHP Gurus here?

Whatever...

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
bupaje
Posts: 1175
Joined: Fri Nov 12, 2004 5:44 pm
Location: California
Contact:

Any PHP Gurus here?

Post by bupaje »

I have a PHP question and was wondering if there are any php coders who might answer a post?
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

Is PHP particularly wierd? I look at a lot of languages ang try to bang some meaning into my head. A lot of the web specific stuff I don't get at all. I guess that means I'm getting to be an old fart.

Sonny, in the olden days.....


Sorry, that was particularly useless. My apologies. I'd help, but I....can't.
User avatar
bupaje
Posts: 1175
Joined: Fri Nov 12, 2004 5:44 pm
Location: California
Contact:

Post by bupaje »

Not really. The truth is I just want to modify something simple without having to learn the whole ding dong language. ;) I started reading the tutorials, found what I need but can't quite get it right. I've got so many irons in the fire the last thing I want to do is to go off on yet another side trip for a tiny bit of code. :) I posted on a php forum and hopefully when I wake up I'll have a solution - but then I tend to run to an unrestrained optimism that defies all the actual facts of my existence. ;)
User avatar
jorgy
Posts: 779
Joined: Sun Sep 05, 2004 8:01 pm
Location: Colorado, USA

Post by jorgy »

If you don't get an answer on the php board, feel free to post it here. :-)
User avatar
bupaje
Posts: 1175
Joined: Fri Nov 12, 2004 5:44 pm
Location: California
Contact:

Post by bupaje »

Ok, will try it here.

I am using the free cms from www.websitebaker.com and I just want a slight modification to add images to the menu and haven't been able to get it right.

This is the relevant line in the function and I have manged to get it altered a bit by looking at examples.

// Function to generate menu
function page_menu($parent = 0, $menu_number = 1, $item_template = '<li[class]>[a]<img src="/media/icons/[page_title].gif" height="16" width="16" border="0" />[menu_title][/a]</li>',

it works and produces the link but [page_title].gif returns the page name with blanks like so

src="/media/icons/Paint Shop Pro.gif"

all I need is to either collapse the spaces or replace them with '_'

I started working through the tutorials on zend.com and tinkering with ereg_replace and str_replace but truth is I'm more art guy than programmer and I'm stumbling around at this point adding quotes and removing them randonly trying to get it to work.

Just a simple solution if possible; they are releasing new versions every couple of weeks and I've already changed my template twice so this is probably just another patch until the next major version.

I can make a simple example work like so

$phrase = '<p>Here I am</p>';
echo $phrase;
$phrase = ereg_replace (' ','_', $phrase);
echo $phrase;

correctly produces 'Here_I_am'

but getting it in that line the right way is beyond me.

Any help appreciated.
User avatar
JohnO
Posts: 14
Joined: Sat Dec 04, 2004 9:45 pm
Location: Mercia, England

Post by JohnO »

bupaje,

Is there any particular reason you need to eradicate the spaces from the filenames? Is it just to return valid URLs? If the filenames actually have spaces, rather than rename them all you could try the following ...

Code: Select all

... <img src="/media/icons/', urlencode([page_title]), '.gif" ...
which should result in something like...

Code: Select all

<img src="/media/icons/Paint%20Shop%20Pro.gif ...
... which is a perfectly acceptable URL.

It's been a while since I did any serious playing with PHP, so the syntax of the above may not be 100%. :oops:

Sorry if this is not what you're trying to achieve.

beo gesund
Eall cræft unnytt bið þonne Engel on þinum flintloce micgeð
User avatar
bupaje
Posts: 1175
Joined: Fri Nov 12, 2004 5:44 pm
Location: California
Contact:

Post by bupaje »

This is just sort of a hack until someone creates an image v=nav menu. I am simply taking the page name and appending the .gif. I then name my images to match. I thought I should remove the spaces or add the '_' as I wasn't sure if the image url would be correct with the spaces.

I couldn't get urlencode to work righ yet -I think it may be just the ' " as I get confused over when to use which one; however because of your remark I did upload an image with the spaces in the name and it encodes it automatically as in your example 3D%20Game%20Studio.gif so I guess I don't need to worry about it.

Sort of a mess as I note that the names are case sensitive as well but this should work fine until some 'official' solution is added to the cms.

Thanks very much for the suggestion. :)
User avatar
cribble
Posts: 899
Joined: Wed Aug 04, 2004 12:42 pm
Location: London, UK
Contact:

Post by cribble »

i wish i knew PHP :( just don't have the time to learn it.
--Scott
cribble.net
User avatar
bupaje
Posts: 1175
Joined: Fri Nov 12, 2004 5:44 pm
Location: California
Contact:

Post by bupaje »

I want to learn everything but I tend to learn just the barest of anything since I jump around. Forcing myself to try to spend my little free time on some classes and Moho when I have play time. :)
User avatar
bupaje
Posts: 1175
Joined: Fri Nov 12, 2004 5:44 pm
Location: California
Contact:

More PHP Help

Post by bupaje »

Hi again. I am trying to install the cpdynalinks package from http://www.cplinks.com The links on the produced page are 'wrong' it appears because I cannot upload the required .htaccess file which rewrites the links it looks like.

rewriteEngine on
rewriteRule ^cat/([^/]+).html$ category.php?category=$1
rewriteRule ^page/([^/]+)/([^/]+).html page.php?category=$1&sub_category=$2

Unfortunately SBCYahoo Webhosting doesn't allow you to upload any files with a preceding . or _ and renaming it the code doesn't work. Can anyone who knows PHP clue me in? Can I run this code from a .php file instead of .htaccess somehow?
[url=http://burtabreu.animationblogspot.com:2gityfdw]My AnimationBlogSpot[/url:2gityfdw]
User avatar
jorgy
Posts: 779
Joined: Sun Sep 05, 2004 8:01 pm
Location: Colorado, USA

Post by jorgy »

I don't think there's an easy way to do it in php. What is happening is that the .htaccess file is a directive to apache, the web server, and happens even before your php script is being run.
Post Reply