tinybutstrong stop showing [var.myvariable] in loaded page when variable is not set - tinybutstrong

I have an html page that is being rendered with the template engine tinybutstrong.
The problem I have found is that if I have a variable that is not set in the php file, when the page loads, it shows
[var.myvariable]
is there a way to stop this without having to declare all variables in the php file
i.e.
$myvariable = '';

Use parameter noerr on each TBS field that you'd like to force the merging without error.
[var.myvariable;noerr]

Related

Laravel - Get HTML of current page or of a view according to a path

I have a view mypage.blade.php and a route.
The url is like : https://example.com/mypage/param1/param2. The route use param1 and param2 and generate the page.
Question 1
In that page, I try to get its HTML code. Is there a way to do it?. I tried render() but I don't get what I want.
Question 2
In the view, can I get the HTML code of an other view by specifying a path ?
You had the right idea. Not sure why it wouldn't work for you.
In the controller, set the view into a variable:
$view = view('myBaseView', compact('people', 'places', 'things'));
Now, if you dump the rendered view variable, you have the page's HTML:
dd($view->render());
To get the html of another view by specifying the path and using the internal controller, you would need to set up some kind of a wrapper or catch so that the view variable is not returned as a view, but rendered out to html as above. Your method would need to trap whatever the original controller was sending before it pushed out the view.
Of course, old school php can get the other page's rendered html too possibly if your server is set to allow this:
$html = file_get_contents('http://mypage.com/');
Something else you might find handy is the Laravel sections method. If you just want to render part of the page you can do so by calling whatever section you want from a partial view:
$sections = $view->renderSections(); // returns an associative array of 'content', 'pageHeading' etc
dd($sections['modalContent']); // this will only dump whats in the content section
I don't know what you want to do with this html, but if you wish to display it on a page, once you send it (you'd possibly want to return the view along with a compact of the variable $view... as a normal variable if so), remember to use this format:
{!! $view !!}
HTH

phpbb variable empty on custom page

I have a phpbb 3.1 forum, where I have put a html portal, (using the custom page tutorial)
I have included functions.php so I can use {S_USERNAME} and everything with the S_ in that page...
but, now I want to put the forum statistics, using, for example:
{TOTAL_USERS_ONLINE}
{LOGGED_IN_USER_LIST}
{TOTAL_POSTS}
and so on
The variables, are empty when using them in my page... is there any problem? I need to add something more than that file?
thanks!
The variables are mentioned are initialized in the page_header function in functions.php
In custom pages you always call that function to initialize common variables like the S_ variables you mentioned.
Since the loading of online users is a little heavier and not needed on every page, the function has a parameter $display_online_list to enable it.
Check the method signature and set $display_online_list to true
To display TOTAL_POSTS, you will need to add a bit of code, see the assign_vars call in index.php, $config is a global variable which should be available in every page.

How to change load layout in Joomla view?

By default parent::display($tpl); loads components/com_my_component/views/my_component/tmpl/default.php, but in some cases i need to load other php file which is in the same folder near default.php (for example components/com_my_component/views/my_component/tmpl/lol.php). How to do this from view.html.php.
P.S.
Tried load loadTemplate and setLayout methods with no luck.
Solved the problem by myself. Need to use the method setLayout and pay attention to the input syntax
$this->setLayout('dafault:lol');
parent::display($tpl);
By default, joomla looks for the layout keyword in the URL to decide which layout to display. If this variable is empty or not present then the tmpl/default.php layout will be loaded.
By editting your view.html.php file you can set the default layout by using the JView API, e.g. $this->setLayout('lol') will make the URL example.com/yourview equivalent to example.com/yourview?layout=lol.
However, this change alone will result in Joomla overriding it's default behaviour so that the layout request will be ignored. This means that the request example.com/yourview?layout=lmao will also display example.com/yourview = example.com/yourview?layout=lol
You can solve this easily by adding a condition around the setLayout function so that only if the layout keyword is not present then you will set the default layout to lol, e.g.
<?php
# ...
function display($tpl = null) {
# ...
# Edit : Set the default layout to 'lol'
$layout = JRequest::getWord('layout', '');
if (empty($layout)) $this->setLayout("lol");
// Display the view
parent::display($tpl);
}
# ...
I keep coming back to this and I've yet to find a satisfying solution.
What does work, from J1.5 right up to J3.4, for me has always been to set the $tpl variable in view.html.php
If $tpl is empty or "" then tmpl/default.php is displayed by default.
If you change $tpl to a string, e.g. $tpl="stacker" then it will look for and display tmpl/default_stacker.php
I've seen various differing theories on changing it earlier in the MVC so that it doesn't need the default_ pretext. e.g. tmpl/stacker.php
None have worked for me.

loading view in codeigniter

HI I have a codeigniter controller called CIcontroller and I have a method say redirectmethod
in the redirectmethod i have some code and then i do this
$data['redirect_page'] = 'page_name';
$this->load->view('template_view',$data);
the template view basically loads header footer and the corresponding view as specified by the data parameter
Now everything works fine but my url has value http:\\blabla\CIcontroller\redirectmethod instead of http:\\blabla\page_name
could anyone help me fix this thing
You need to emit a Location header to tell the browser to load a different page. See redirect in the url helper.

Create base jqgrid

I have a website with several views, and most of them have a jqGrid on them.
I'd like to set some base options on all my jqgrids. For example, I'd like the view option to always be set to true, and the search option to always be set to false.
Additionally, there are several that I'd like to have the same button labels.
Is there any way to do this with a jqGrid?
Look at the answer which shows how to set default settings jQuery.jgrid.nav. In your case it would be
jQuery.extend(jQuery.jgrid.nav,
{search:false,view:true, viewtext:"View label", viewtitle:"View tooltip"}
);
Other default settings you can change in the same way using jQuery.jgrid.del, jQuery.jgrid.view and of course jQuery.jgrid.defaults.
You don't need to place the code inside of jQuery(document).ready(function() {/**/});. It is enough just ecxecute the code like jQuery.extend(jQuery.jgrid.nav, {search:false,view:true}); inside a JavaScript file loaded after the jquery.jqGrid.min.js.
You could add an additional script tag to your HTML that references a JS file with some base configuration stuff for the grid in a $().ready(function() {}); block.
You could also create a base configuration function or variable that you store in that external JS, and reference that configuration on each view page.
I would prefer to write the base function, and not the ready event handler as the ready handler will NOT run at a predictable time. You won't know if it properly ran before your jqGrid configure function ran.

Resources