Author |
Message |
Rumbaar
Regular


Joined: Apr 16, 2004
Posts: 78
Location: Melbourne, Australia
|
Posted:
Fri Apr 28, 2006 5:38 am |
|
It's only a small thing, but I think it makes a theme more user friendly and better integrated in the Topics module with theme specific images.
I found that various themes don't make any reference to the possibility for a theme specific topic image, based on defined topic images.
So the minor change needed in your theme.php for the News to display the 'correct' Topic image if available.
For the functions;
function themeindex ()
function themearticle ()
Add in the following code after the global variables.
Code: $ThemeSel = get_theme();
if (@file_exists("themes/$ThemeSel/images/topics/$topicimage")) {
$t_image = "themes/$ThemeSel/images/topics/$topicimage";
} else {
$t_image = "$tipath$topicimage";
}
|
The important next step is to modify the theme's reference for displaying the image from most likely $tipath$topicimage to new $t_image variable.
This should make sure that the News page will follow the same display settings you'll find in your Topics module. |
_________________ Victim's aren't we all! |
|
|
 |
montego
Site Admin

Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Fri Apr 28, 2006 5:55 am |
|
Excellent hack! I have always wondered why my Topics graphics could not be Theme specific. I have also have always wondered about Language specific Topics (because many graphics have text on them too)... |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
 |
Guardian2003
Site Admin

Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam
|
Posted:
Fri Apr 28, 2006 6:10 am |
|
Excellent hack Rumbaar - well done.
That is certainly a useful hack!!
I have made this post a sticky. |
|
|
|
 |
Rumbaar

|
Posted:
Fri Apr 28, 2006 11:09 pm |
|
Why thank you. I almost didn't post as I thought it was far too simple of an idea and that it would have already been 'common' knowledge among the nuke theme community. I'm glad I did now.
I had been working on various themes for a games site I run and found the images weren't showing up and wondered why. At first I though it was due to my custom themes, but found it applied for various other default themes around the place.
Also another important point I'd like to make is that any theme specific topic images have to be the exact same name and file extension as the 'base' image that was defined when you created the theme.
If there are some coding wizards out there, the only modification I would like to see in the code would be for it to only check the file name excluding the file extension. This will allow for people to use different file types like png, jpg or gif across theme without much issue. |
|
|
|
 |
montego

|
Posted:
Sun Apr 30, 2006 9:47 am |
|
Personally, I feel that the Topics and News modules should be enhanced to allow for language specific topic icons. But, who has the time... |
|
|
|
 |
Rumbaar

|
Posted:
Sun Apr 30, 2006 9:40 pm |
|
Enhanced for language specific icons, in the same way the forums allow for language specific icons?
Just a question do you or anyone know if the forums take the language definition from the core php-nuke or from it's own files and includes. I see the {LANG} variable in the icons definition but can't seem to locate where it defines this variable.
If I could find this I'm sure it could be borrowed and with a few tweaks and modifications incorporated into the Topic and Theme/News sections.
I'll continue to look, but it sounds do-able. I'm sure a slightly hard-coded one could be done fairly easily (ie look for a themes/$ThemeSel/images/topics/lang_".$currentlang."/$topicimage as well as the 'default' path/s) but I have to think of all the possibilities that a hard-coded code might not function with. |
|
|
|
 |
Rumbaar

|
Posted:
Mon May 01, 2006 5:42 am |
|
Ok montego,
'Cause you asked, language specific topic icons.
I'll look to add this hack as a new thread if I can work out which section to put it in.
----------------------------------------------------------------
I have tested this to the best I could, but as I don't use any other language than English I can't say how it will function with 100% certainty with other languages.
Open topics->index.php
find:
Code:$ThemeSel = get_theme();
if (@file_exists("themes/$ThemeSel/images/topics/$topicimage")) {
$t_image = "themes/$ThemeSel/images/topics/$topicimage";
} else {
$t_image = "$tipath$topicimage";
}
|
and replace with:
Code: $ThemeSel = get_theme();
if (@file_exists("themes/$ThemeSel/images/topics/lang_".$language."/$topicimage")) {
$t_image = "themes/$ThemeSel/images/topics/lang_".$language."/$topicimage";
} elseif (@file_exists("themes/$ThemeSel/images/topics/$topicimage")) {
$t_image = "themes/$ThemeSel/images/topics/$topicimage";
} elseif (@file_exists("images/topics/lang_".$language."/$topicimage")) {
$t_image = "images/topics/lang_".$language."/$topicimage";
} else {
$t_image = "$tipath$topicimage";
}
|
For any theme you are using you'll need to make modifications to the following functions:
function themeindex ()
function themearticle ()
Now if you made the modifications listed in the first post of this thread you'll have to change the code to reflect the new code posted above. You will also have to add the variable $language to the GLOBAL variables in each of the two listed functions.
----------------------------------------------------------------
I've created the code to look for certain files in a specific order to best meet the needs of user.
In order of checking, using english language for examples;
1. theme->topics folder->lang folder - (ie, /html/themes/test/images/topics/lang_english/sample.jpg) - This is for a theme that has a language topic folder(s).
2. theme->topics folder - (ie, /html/themes/test/images/topics/sample.jpg) - This is for a theme that just has base theme specific topic icons.
3. images->topics folder->lang folder - (ie, /html/images/topics/lang_english/sample.jpg) - This is if the default config has language folder(s).
4. images->topics folder - (ie, /html/images/topics/sample.jpg) - This is the base default topic icons.
So all you need to do for your topics theme or language specific images is to create a folder as per example above lang_language. It shoud be as simple as that.
----------------------------------------------------------------
I wasn't quite sure of the difference between $currentlang or $language so I'm not sure of the ramifications across the whole php-nuke coding. If someone can tell me the difference or tips please post.
I hope you and/or others find this useful. I also ask if people can test on multiple languages and let me know if they run into any issues.
Enjoy, |
|
|
|
 |
Rumbaar

|
Posted:
Mon May 01, 2006 4:47 pm |
|
Actually I was thinking later, to make it more in line with the variable nature of php-nuke it would be best for the 'default' language test to point to the defined Topic image path than the hard coded one I put in.
So I would suggest change:
$t_image = "images/topics/lang_".$language."/$topicimage";
to:
$t_image = "$tipathlang_".$language."/$topicimage";
But I haven't tested this code live yet (due to me being at work), I think the syntax for joining a variabl result with static text might be wrong. |
|
|
|
 |
|