Any PHP Gurus here?
Moderators: Víctor Paredes, Belgarath, slowtiger
Any PHP Gurus here?
I have a PHP question and was wondering if there are any php coders who might answer a post?
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.
Sonny, in the olden days.....
Sorry, that was particularly useless. My apologies. I'd help, but I....can't.
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.
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.
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.
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 ...
which should result in something like...
... 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%.
Sorry if this is not what you're trying to achieve.
beo gesund
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" ...
Code: Select all
<img src="/media/icons/Paint%20Shop%20Pro.gif ...
It's been a while since I did any serious playing with PHP, so the syntax of the above may not be 100%.
Sorry if this is not what you're trying to achieve.
beo gesund
Eall cræft unnytt bið þonne Engel on þinum flintloce micgeð
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.
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.
More PHP Help
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?
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]