1

I'm doing some modifications on a carpark booking system created by PHPJabbers. https://www.phpjabbers.com/car-park-booking/ I don't know much about php and it's sturcture. I think my question will be answered very soon because it must be a very simple one:D

I have views and controllers. As I imagined, controllers give content to views. In every php file in the views folder I see a php variable called tpl.

Like in this:

" class="pj-form-field number w80" readonly="readonly"/>

the url's end looks like: index.php?controller=pjAdminBookings&action=pjActionUpdate&id=12579

(the action is the name of the php file in views) I tried to search the whole project for it's source but I could never find anything. For exmaple I searched for ['option_arr'] and everything I found was in views and was the key of tpl variable. (Once a thought I did find it in the controller named in the url... now it's not the case)

I hope you can understand the question despite my poor english. Thank you!

ormi
  • 21
  • 1
  • 4
  • Oh, here is a picture of the code I tried to paste.. https://i.stack.imgur.com/qjcKR.png – ormi Nov 24 '18 at 20:16

2 Answers2

2

You haven't really given us enough information to be 100% certain ...

... but "tmp" probably stands for "template".

In this link, the PHP framework was "Smarty": What is .tpl files? php, web design

"So what is a 'template'?", you might ask?

https://www.dummies.com/web-design-development/html5/using-templates-with-php/

As web development becomes standardized, the Model-View-Controller (MVC) architecture has become more popular. The basic idea of this mechanism is to separate the data elements (the model), the user interface (the view), and the code that connects the model and the view (the controller).

Many programming instructors emphasize separating content, layout, and data. However, the way PHP is often written, it combines all three elements. As a response, web developers often use some form of templating system to try to separate the content from the view.

To get a feel for this, I encourage you to try either of these tutorials:

ADDENDUM:

It turns out that that your app, PHPJabber, uses it's own, home-grown MVC/Template framework:

Please read the tutorials about "Twig" and/or "Smarty". This will help you understand what's going on with PHPJabber. Specifically, it should help you understand the "what" and the "why" of your "tpl" variables, and how they relate to the "controller" rendering a "view".

paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • Sorry I was not clear. I don't really know what to tell. I don't have any .tpl files. And nothing is imported in any file in the folder views. – ormi Nov 24 '18 at 20:25
  • Yes. But you have tpl *variables*. Which, I'm pretty sure, are for "templating". I absolutely encourage you to spend a few minutes looking at some of the links I mentioned. Understanding the links should help you better understand your code. – paulsm4 Nov 24 '18 at 20:28
  • Oh!! Thank you for the link!! I have only superficially checked phpjabbers.com. It was a mistake. Now I'm enlightened. This explains so much!! Thanks again. :) – ormi Nov 24 '18 at 20:56
0

If i am right the controller has to be the pjAdminBookings. The method the controller is using is pjActionUpdate. In this method there should be a return which uses a function which return the variables. I hope it helps.

Vaggelis Ksps
  • 308
  • 4
  • 13
  • This is the beginning of pjAdminUpdate.php. http://i67.tinypic.com/zuikxw.png It just uses $tpl.. – ormi Nov 24 '18 at 20:31
  • it looks like that another file requiring controller files according to querystring. In this file has to be a $tpl variable. Hard to say without viewing your project. – Vaggelis Ksps Nov 25 '18 at 14:55
  • Yes, you are right but there is no return or $tpl in the controller but "->set('latest_bookings', $latest_bookings)" and in the view I can access this from $tpl['latest_bookings']. I thought it is such on obvious thing that every php programmer uses this method. – ormi Nov 26 '18 at 15:51
  • The way that variables are passed to the view depends on the framework and the template engine as @paulsm4 mentioned before. In the end everything resolves in plain php but the process is different. – Vaggelis Ksps Nov 26 '18 at 18:22