Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
/path/to/site automatically?
<txp:site_url />files is a great way of producing http://mysite.com/files but is there an equally convenient way to extract the path to site such as:
/home/whatever/public_html/files or
/users/home/whatever/public_html/files or even
/htdocs/mytest/files
I am going to be using zem_ir image replacement plugin and paths such as these are needed. As I am using it for a template, and there are several instances of the path that would need to be changed, some kind of automatic production of this path would help a lot.
Dozy P My attempt at music
Offline
Re: /path/to/site automatically?
The constant ‘hu’ always points to the root of your textpattern install.
Offline
Re: /path/to/site automatically?
Thanks, Ruud! I just tried font=”<txp:php>echo hu</txp:php>/files/copper.ttf” and it all seems to work just fine :-)
Dozy P My attempt at music
Offline
Re: /path/to/site automatically?
I spoke too soon. I must have been seeing cached pages. I’ve tried a few things such as:
font=”<txp:php>echo hu. ‘files/copper.ttf’;</txp:php>”
but it produces this error message:
Error: The server is missing the specified font ‘C:/xampp\http://localhost/minim/files/copper.ttf’.
So it seems to be mixing up the url and path.
Dozy P My attempt at music
Offline
Re: /path/to/site automatically?
Please post your diagnostics here.
Offline
Re: /path/to/site automatically?
Here you are. The prefs changes is to enable comment preferences. The clean url test has failed for about 6 months but not affected anything as far as I can tell. It always used to work before that.
————————-
Textpattern version: 4.0.4 (r1956)
Last Update: 2007-06-29 18:29:33/2006-08-31 16:47:58
Document root: C:/xampp/htdocs (C:\xampp\htdocs)
$path_to_site: C:\xampp\htdocs\minim
Textpattern path: C:\xampp\htdocs\minim\textpattern
Permanent link mode: section_title
upload_tmp_dir: .;C:\xampp\tmp
Temporary directory path: C:\xampp\htdocs\minim\textpattern\tmp
Site URL: localhost/minim
PHP version: 5.0.4
Server Local Time: 2007-07-06 16:31:27
MySQL: 4.1.12
Locale: English_United Kingdom.1252
Server: Apache/2.0.54 (Win32) mod_ssl/2.0.54 OpenSSL/0.9.7g PHP/5.0.4
Apache version: Apache/2.0.54 (Win32) mod_ssl/2.0.54 OpenSSL/0.9.7g PHP/5.0.4
PHP Server API: apache2handler
RFC 2616 headers:
Server OS: Windows NT 5.1
Active plugins: hcg_templates-0.3, zem_contact-0.6, glx_hl_current-0.3, upm_savenew-0.4, zem_ir-0.5m
Pre-flight check:
————————————
Some Textpattern files have been modified: /include/txp_prefs.php
Clean URL test failed.
————————————
.htaccess file contents:
————————————
#DirectoryIndex index.php index.html
#Options +FollowSymLinks
#RewriteBase /relative/web/path/
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.+) – [PT,L]
RewriteRule ^(.*) index.php </IfModule>php_value register_globals 0
————————————
Last edited by zero (2007-07-06 15:37:19)
Dozy P My attempt at music
Offline
Re: /path/to/site automatically?
If you just do <txp:php>echo hu;</txp:php>, what does that show as a path?
Offline
Re: /path/to/site automatically?
I get ‘cannot create heading’ but if I put
font=”<txp:php>echo hu;</txp:php>files/copper.ttf”
I get:
Error: The server is missing the specified font ‘C:/xampp\http://localhost/minim/files/copper.ttf’.
I just tried this on a website with clean urls working and have the same problem.
I am putting this inside <txp:zem_ir_set. I’ve used it in a form and on a page but still the same results.
Dozy P My attempt at music
Offline
Re: /path/to/site automatically?
Hmm… but I think I misunderstood you, because you probably want the path on the server, instead of creating an URL (which “hu” is used for), so try this:
<txp:php>global $path_to_site; echo $path_to_site;</txp:php>
Offline
Re: /path/to/site automatically?
Yes, I don’t want a url. I tried exactly what you wrote and now get this:
Error: The server is missing the specified font ‘C:/xampp\C:\xampp\htdocs\minim/files/copper.ttf’.
So it’s a little bit nearer…
Dozy P My attempt at music
Offline
Re: /path/to/site automatically?
That’s weird… what happens if you put the last bit of code I suggested in a TXP template alongside other plain text and then visit a page that uses this template. I’m interested in seen what value $path_to_site has.
I think somewhere in the plugin the “c:/xampp\” part is added.
Offline
Re: /path/to/site automatically?
Note that if I put copper.ttf in the xampp folder it all works. However, I want to be able to upload the font to the files folder via txp file upload.
Zem_ir creates and uses xampp/images/zir folder by default, and seems designed for fonts to go directly in the xampp folder so they are out of the public_html to prevent font downloads. However, there’s a fontdir and a font option to specify different paths, but these don’t work with url but only with server paths. So I want to create a server path automatically so any user of the template doesn’t have to mess about changing server path names.
Dozy P My attempt at music
Offline
Re: /path/to/site automatically?
We posted at the same time :-)
I get the correct path like so:
C:\xampp\htdocs\minim\hello
So it’s a zem_ir thing then…
Dozy P My attempt at music
Offline
#14 2007-07-09 00:14:13
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: /path/to/site automatically?
How paths work in PHP is relevant: by default if you don’t supply an absolute path, it will use the current file’s position as the starting point.
The other part of the problem is that you won’t get expected results if you try to embed PHP within a tag like that. Try using $path_to_site, but use the PHP verson of the entire tag, not just for the font attribute value.
Offline
Re: /path/to/site automatically?
I’m not sure how I would do that when I have this tag!
<txp:zem_ir_set group=“h3” font=”/htdocs/minim/files/copper.ttf” fontsize=16 backgroundcolor=”#111” color=”#ccc” transform=“lowercase” wraptag=“h3” padding=“1 3 1 0” />
However, I am no longer going to worry about it. I can use the path for my own purposes and for template users, just put font=“copper.ttf” and ask them to put the font beyond the public_html folder. They should all have ftp access or how did they install txp in the first place?
But thank you Ruud and Mary. I now understand it better and know the answer to my original question: ie $path_to_site. Wow, I almost had the answer when I wrote the topic /path/to/site :-)
Dozy P My attempt at music
Offline