e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
321 stars 213 forks source link

Templates (theme templates) #402

Closed mcpeace-maw closed 8 years ago

mcpeace-maw commented 11 years ago

I moved forum_icons_template.php in my theme and make changes but seems this template is not used from the theme. I moved the file in templates folder inside the theme and nothing. I think an alternative solution to customize the forum icons is to use a custom forum_icons_template.php inside templates folder in the theme (active theme) that use png, svg or font icons from the theme. And another thing, please move all templates file inside templates folder of the theme in individual folders like news template, now some templates files like login_menu_template are in the theme root.

Moc commented 11 years ago

The way templates are stored has changed in v2.x, while retaining backwards-compatibility: The preferred way is a folder called 'templates' in your theme folder. Your folder structure then becomes _e107_themes/themename/templates/

Currently the methods described above are not functioning completely yet. This is a work in progress. At this point there are inconsistencies in the template calling. This will be sorted out as development progresses. You can try and see if the forum templates overrides are working properly by creating the following structure: _e107_themes/themename/templates/forum/

Side note: The forum plugin is undergoing lots of work still, so it will have numerous changes.

mcpeace-maw commented 11 years ago

OK, but the problem with forum_icons_template.php exit, I looked on forum files and is searched just in the forum folder not in the theme first like the other templates. I think is a good thing if is searched first in the theme and if is not there, to search it in the forum folder.

Moc commented 11 years ago

You are right, this is the order in which templates are (should be) called by e107 core (in this case for the forum plugin):

1) e107_themes/theme_name/templates/forum/ 2) e107_plugins/forum/templates

As said in my previous reply, this is not functioning properly in all areas of e107 v2 yet. It's a work in progress.

CaMer0n commented 11 years ago

Best to use this path:

e107_themes/YOURTHEME/templates/forum/forum_icons_template.php
Moc commented 10 years ago

I think this is now fixed, please re-open if necessary.

rica-carv commented 8 years ago

Sorry to say, but i think i got this same issue.... I'm trying to customize the news_template.php from the news plugin, and until now, i got no luck.... I even got 3 copies of news_template.php spread across my theme:

Without any luck, the news always renders with the news plugin template.....

I've got the latest github core files, so any ideias what's happening???

LaocheXe commented 8 years ago

you try renaming it to news.php in your theme folder?

mcpeace-maw commented 8 years ago

This was resolved log time ago.

rica-carv commented 8 years ago

@LaocheXe In my mail theme folder???? @mcpeace-maw It could be resolved long time ago, but it seems to have come back.....

mcpeace-maw commented 8 years ago

Working properly. No offense but I think you should do distinction between real e107's issues which are posted here and your learning problems. Please use e107Help for that.

rica-carv commented 8 years ago

@mcpeace-maw In my setup, a custom news_template.php inside a theme doesn't work, despite e107 runs the php file (i know it runs it, since i've placed echo's inside and they are shown...). So, for me, this is a bug, not my learning problems.....

And by the way, which learning problems??? Documentation is poor, so we all got to learn by ourselfes, indeed.... but it's not easy....

Moc commented 8 years ago

@rica-carv Please see this issue for an explanation of how the template overrides work: https://github.com/e107inc/e107/issues/666#issuecomment-46752127 I'll integrate this in the documentation on e107.org over the coming few days.

In your case:

The news template is located in e107_plugins/news/. To override this template, copy the file over to e107_themes/your_theme_folder/templates/news/.

If doing so doesn't work, then it can be considered a bug. I don't think this is the case though, as it seems to function fine on my installs, but please check to be sure.

EDIT: Documentation now updated. http://e107.org/developer-manual/theme-basics#overriding-core-templates

rica-carv commented 8 years ago

@moc As i've stated before, i've tried several approaches:

I even got 3 copies of news_template.php spread across my theme:

  • one on the themes parent folder,
  • other on the template folder inside the theme,
  • another on the template/news folder inside the theme....

After these tests, i found out that the news_template.php has to be on the base theme folder (as the code inside news.php below calls...), not inside the e107_themes/your_theme_folder/templates/news folder, as you say....

In your case: The news template is located in e107_plugins/news/. To override this template, copy the file over to e107_themes/your_theme_folder/templates/news/.

So your ideia doesn't work. Check the code of news.php, lines 774-777:

if(isset($pref['news_unstemplate']) && $pref['news_unstemplate'] && file_exists(THEME."news_template.php"))
{
    // theme specific template required ...
    require_once(THEME."news_template.php");`
mcpeace-maw commented 8 years ago

Install bootstrap3 core theme (original one not the one you mode), copy news_template.php from news plugin folder in bootstrap3/templates/news/ folder, open it and search for $NEWS_TEMPLATE['default']['item']=' '; , put some text inside before first div, after open news page and the text added will be before every news.

Moc commented 8 years ago

@rica-carv Having multiple templates with the same name in there is of course not the way to go, but I suppose you did this for testing.

So your ideia doesn't work

It is not my idea. This is the new standard in v2. If this doesn't work then it's simply a bug which needs fixing.

I'll do some testing asap and I'll get back to you.

rica-carv commented 8 years ago

@mcpeace-maw

Install bootstrap3 core theme (original one not the one you mode), copy news_template.php from news plugin folder in bootstrap3/templates/news/ folder, open it and search for $NEWS_TEMPLATE['default']['item']=' '; , put some text inside before first div, after open news page and the text added will be before every news.

The bootstrap3 core theme has no such template, check here in github source....

@moc

Having multiple templates with the same name in there is of course not the way to go, but I suppose you did this for testing.

Yes, of course i did this just for testing, and before i go scavenge the news.php code to figure out what was the issue....

mcpeace-maw commented 8 years ago

"copy news_template.php from news plugin folder"

I waste my time to teach you how to test this issue and you can not even read my post? You can not create news folder in bootstrap3/templates and paste a copy of that file in it? Forget it.

rica-carv commented 8 years ago

@mcpeace-maw Sorry, but i misunderstand you, i thought i had to fetch news_template on the bootstrap 3 theme/templates/news, and copy from there... Now i understand, so i'll try and let you know....

rica-carv commented 8 years ago

What the heck? Now it works as intended. Simply, i can't understand it.... Got E107 cache off, got browser cache off..... Can't really figure out what the hell happened....

Please excuse me for all this trouble, but seriously, this morning this wasn't working, and now it is.... And many thanks all for all the help....

mcpeace-maw commented 8 years ago

It is OK, right? Well that is the way to test an issue, change the theme with a core one (now bootstrap3 is the only one) and if you can replicate the same issue with the core theme, it is an e107 issue and post the issue here, if not then the issue is in your theme.

rica-carv commented 8 years ago

Errr, sorry to bother again, but it seems that the custom news_template.php bug is back again, and this time, with a little twist: If i'm logged in, news_template.php comes from the core: untitled 1

If i'm logged out, it loads from the theme folder: untitled 2

Images when testing with bootstrap3 core theme...

Moc commented 8 years ago

@rica-carv Do you have caching enabled in the admin area? If yes, disable and clear all of them and see if that makes any difference. Also, make sure you are using the latest files from Github.

Then, the custom template should be located in: e107_themes/yourtheme/templates/news/news_template.php Is this indeed the case?

rica-carv commented 8 years ago

@Moc I've got cache disabled, and cleaned... I've got files for 2.1, but i was unable to do the update from admin area today (gives error), so got to download them directly from github and update. Now got version 2.1.2 (git). And yes, template is in the correct location: (e107_themes/bootstrap3/templates/news/news_template.php). Issue still persists.....

CaMer0n commented 8 years ago

@rica-carv news.php, lines 774-777 dates back to v1.x. It's possibly a candidate for removal. In your news preferences, make sure "Use non-standard template for news layout" (also a candidate for removal) is "Disabled"

rica-carv commented 8 years ago

@CaMer0n I've already tried enable & disable on the "Use non-standard template for news layout" switch. Issue still persists with any of the options....

rica-carv commented 8 years ago

Goddamn, forget it.... My fault (once more). For the record, i was updating v2.1.2 with the upgraded v1.4 to v2 database data, and on the user table, i had on my username row, this data on the user_prefs field: a:1:{s:9:"sitetheme";s:0:"";} Seems it was old v1.4 data, so i cleaned it up and issue solved.... Sorry for all the trouble....