SMF: 1.1.5
TP: 0.9.8
I tried a search for 'hard code icon' or even 'moving TinyPortal' but didn't find anything, so sorry if this has been posted before.
But I've noticed, at least for now, the download icon field has the path to the icon is the full hard coded URL. I really don't understand the need for an absolute path. As the download file is a relative, but the icon which is a sub-folder of that relative path is hard coded.
Is there a 'repair_settings' tool for the hard code strings for TP, or does anyone know of any other fields that are hard coded. So when I move I know what to look for?
Thx,
Rumbaar
Not sure I get your meaning Rumbaar, but the paths that may need to be corrected would be corrected by the SMF file repair_settings.php.
Another Team member may correct me but afaik that would take care of any file path issues that come up as the result of a move.
Okay, I'll try to explain it more.
In the table {prefix}tp_dlmanager, there is a field for the download icon (icon), which is supplied via the drop-down menu when you assign a download.
But in that field in the db you have the full path:
http://localhost/newpublic/tp-downloads/icons/php_file.gif
Where the data for the actual data (file) is stored:
testfile.zip
So the icon is hard coded to that path, but the file isn't (which is the way it should be).
It should use the same path the file uses, so would be stored as:
icons/php_file.gif
From the code that I've looked at, the icons are always stored beneath the forum's home directory in tp-downloads/icons; the code uses the $boarddir variable to set the path to reference the icon file.
The icons are stored in one location, and dynamically read each time to be selected for file types when you upload the file- i.e. you don't have to have multiple copies of the icon stored with each file, but rather a 'library' of icons.
Yes that is how I would imagine it would work, but it's certainly storing the whole full URL to the icon instead of a path in the current version of TP [0.9.8] I've got installed.
I've looked in my localhost and live install, might be a bug then?
Do you have very many files?
If you could go through a SQL admin interface, you could change the path manually... provided you didn't have very many files, it would be the fastest way to do so.
On the other hand, I can look into making a quick & dirty SQL script to change out the existing path to the current one... but I am about to depart for work, so it will be tomorrow before I can get to that.
Oh I can make the manual changes via SQL, but was just looking to see if it was an issue or other areas that I might need to be aware of. I've only used the standard icons that come with TP so far, and then only 3-4 of them, can globally change that with ease so far.
Would it be much to alter the code (I haven't even looked) to work like it should and use relative paths?
Ah I see the issue now.
$icon= !empty($_POST['tp_dluploadicon']) ? $boardurl.'/tp-downloads/icons/'.$_POST['tp_dluploadicon'] : '';
And then the full URL is passed to the row update un-parsed
db_query("INSERT INTO {$tp_prefix}dlmanager
(name, description, icon, category, type, downloads, views, file, created, last_access, filesize, parent, access, link,authorID,screenshot,rating,voters )
VALUES ('$title', '$text', '$icon' , $category, 'dlitem', 0, 1, '$name', $now, $now, $dlfilesize, 0, '', '', $ID_MEMBER, '$screenshot','','')", __FILE__, __LINE__);
Then when it's called again it takes the whole field
$context['TPortal']['dlitem'][] = array(
...
'icon' => $row['icon'],
Then when called by the template it uses the whole URL to define the image source.
' , $dlitem['icon']!='' ? '<img src="'.$dlitem['icon'].'" border="0" alt="'.$dlitem['name'].'" align="right" style="margin: 1ex; " />' : '' , '
So I guess it will need to take out the base URL in the initial INSERT stage and then use the $boarddir in the icon call at template stage.