News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Questions

Started by demonxanx, January 23, 2016, 12:42:12 AM

Previous topic - Next topic

demonxanx

I'm using SMF 2.0.11.
Here is my website: hxxp:www.moonshade.net [nonactive]

hxxp:prntscr.com/9tny5k [nonactive]
I'm trying to get rid of the links next to my avatar on the index page and replace them with other stuff such as custom fields, post count of said user and membergroup of that user.
What file would I have to edit?

Kindred

if you mean the information in the header - that would be your theme's index.template.php

However, the custom fields and post count are not defined on every page...  So, you are going to have to do some database queries to pull the data into the index for every page
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

demonxanx

Quote from: Kindred on January 23, 2016, 12:53:06 AM
if you mean the information in the header - that would be your theme's index.template.php

However, the custom fields and post count are not defined on every page...  So, you are going to have to do some database queries to pull the data into the index for every page

For future reference. How would I find this information by myself? How would I find out which .php file is responsible for whatever is on my website. xD
Is there anyway to check that in like google chrome f12?

Kindred

not really....


although it is logically determined
the wrapper is index, the other templates are pretty well sorted by name (boardindex, messageindex, display, profile, etc)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

demonxanx

Quote from: Kindred on January 23, 2016, 12:53:06 AM
So, you are going to have to do some database queries to pull the data into the index for every page

I understand this in text format but I'm going to be straight with you, I have no idea how to code it in php/sfm. I'm really sorry but I'm a newbie to both php and smf and it's difficult for me to understand these things. Since SMF has very poor documentation I'm literally just confused so much right now.
If you could I really would appreciate if you could provide such code.

In my index.template.php I have the following line:

<li class="user">', $context['user']['name'], '</li>

This grabs the user name however how would I used the same for membergroups and custom fields, show me code examples please.
Thank you in advance.

margarett

Quote from: demonxanx on January 23, 2016, 02:12:33 AM
Since SMF has very poor documentation I'm literally just confused
Sorry but this is false (and unfair, to be honest).
SMF has its documentation at http://wiki.simplemachines.org/ You can like it more or less but to claim that it's "very poor" strikes me as highly unfair to the people who work and worked in it.

What you are asking is developers' documentation (eg: how to get to the guts of SMF) and we also have some of that, but of course it can't cover every bit of code inside! To change PHP code (be it SMF or any other software), you need to be able to code in PHP, there's just no other way. So you need to look at the code, understand how the variables are filled, how the values are obtained and finally how they are displayed.

$context content changes dynamically depending on the current page you're viewing. In order to see it's content, print_r or var_dump in index.template.php are your friends. Once you know what's inside you can choose to display what's inside. If you want to *change* what's available in $context, then you're looking at the Sources files and that's much more complex. Possible but more complex!
This is worth reading: http://www.simplemachines.org/community/index.php?topic=542018.0

About custom profile fields, again you need to understand how they work. In short, they're not loaded in every page so if you want to pick your own, you can create your custom function to get them. This post should help:
http://www.simplemachines.org/community/index.php?topic=518203.msg3666696#msg3666696
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Illori


Advertisement: