Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
have a problem with get_theme_url()
#1
I have a problem with this function in a php guestbook,when i use get_theme_url in the form action (html) the function work correctly but when i use this in php code for receive guestbook.txt directory ($dirfile=get_theme_url()."/guestbook.txt"; ) it doesn't work beacause it prints the url.How i can resolve?
My Site: The Harad's Forge
Do you want a guestbook on pages or on news manager articles?Download my GS plugin: ARGuestbook
Reply
#2
functions beginning with "get_" will echo the result, "return_" functions will return to a variable...

however there is none for theme_url

you could just use

Code:
$dirfile=$SITEURL . "theme/" . $TEMPLATE."/guestbook.txt";

Mike.
My Github Repos: Github
Website: DigiMute
Reply
#3
Thank you but there is another problem,if i try to echo $dirfile the file url is ok but when i use the function file_exsists($dirfile) it returns false.Why?If i paste the url of $dirfile on my browser,i should be it...
My Site: The Harad's Forge
Do you want a guestbook on pages or on news manager articles?Download my GS plugin: ARGuestbook
Reply
#4
You could use the constant GSTHEMESPATH:

Mike's example would then be:
Code:
$dirfile=GSTHEMESPATH.$TEMPLATE."/guestbook.txt";

However I would rather store it in the data/other path:
Code:
$dirfile=GSDATAOTHERPATH."/guestbook.txt";

List of GetSimple constants here: http://get-simple.info/docs/plugin-creation
Reply
#5
Alessio_roma Wrote:When i use the function file_exsists($dirfile) it returns false. Why?
Because file_exists() needs a path to the file on the server, the browser need the URL where it can retrieve the file. The constants Carlos mention are paths on the server, something like "/public_html/data/other/", and $SITEURL as mentioned by Mike will return something like “http://example.ms/”.

I hope you understand the difference Smile
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#6
thank you very much,now it works!
My Site: The Harad's Forge
Do you want a guestbook on pages or on news manager articles?Download my GS plugin: ARGuestbook
Reply




Users browsing this thread: 1 Guest(s)