How do I pull up DB info based on the logged in user with dynamic gets ? #962
-
Hi, I know how to get the ID of the current user in Joomla e.g. echo JText::sprintf('Hello %s', $this->user->id); Do I need to use Tweak, Joint or Custom script php before getting items? Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Well this will depend on where your code is being run, since the model, view and controller all have their unique way of giving you the user ID, and it will also depend on which Joomla version you are targeting. I would consider this a very broad question and hard to give one simple answer. Ideally those who use JCB will build their component then open the file/class where they want to do custom code, and look at what is available to them. They will also add some identifiable placeholder so they can see where the custom code from the GUI of JCB gets used in the code it generates. Generally this take time and is hard to explain since there are literally hundreds of use-cases all over JCB with many different ways, and that mostly since this is how Joomla in those areas use to work, or still works. That all said in the dynamicGet area we are working in the model, and here we have some helper values in (targeting) Joomla 4 and 5 these values gets you the current user ID. Here you can see the template file used. So you will see a list of values we load by default in the model for use in your code. So to get the user ID in the model
I am not sure how many of the JCB tutorials => wiki you've done, but I can tell you that they are still your best source of knowledge about JCB even though they are old. Assuming you've put in the time... here is a few screenshots of how its done: Hope this points you in the right direction. Take care! |
Beta Was this translation helpful? Give feedback.
Well this will depend on where your code is being run, since the model, view and controller all have their unique way of giving you the user ID, and it will also depend on which Joomla version you are targeting. I would consider this a very broad question and hard to give one simple answer. Ideally those who use JCB will build their component then open the file/class where they want to do custom code, and look at what is available to them. They will also add some identifiable placeholder so they can see where the custom code from the GUI of JCB gets used in the code it generate…