I have the PHP code:
$uid = $xUS['id']; // Current user id
$uname = $xUS['x_username']; // Current user name
$ulink = ''; // Current user profile URL (leave blank for none)
$upic = $xUS['config_forum_avator_head']; // Current user
$ismod = 0; // Is current user a moderator?
$sig = md5($uid . $uname . $ismod . 's79tvi40k95bs6mw');
$ssoParams = '&uid=' . $uid . "&uname=" .
urlencode($uname) . "&ulink=" . urlencode($ulink) . "&upic=" . urlencode($upic)
. "&ismod=" . $ismod . "&sig=" . $sig;</i>
My Smarty template file:
<iframe width='550' height='500' src='http://chatroll.com/embed/chat/pibux-chatroom?id=tgybumotNmY&platform=php{$ssoParams}&w=$0' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' allowtransparency='true'></iframe>
In this, the {$ssoParams} variable is returning a null value. Why? Please help out.
Read Smarty docs for example: http://www.smarty.net/docsv2/en/language.variables.tpl#language.assigned.variables
You need to assign a variable like:
$smarty = new Smarty();
$smarty->assign('ssoParams', $ssoParams); // assign(smarty var, PHP var);
$smarty->display('template_file.tpl');
And of course you need to include smarty files, define templates etc.
For basic working example look example 2.9. here:
http://www.smarty.net/docsv2/en/installing.smarty.basic.tpl#id2778275
Related
I'm setting a variable based on an array. When I echo the variable it displays on the screen, however when I try to add it to a Header Location it doesn't show up in the URL of the next page - everything else does:
$myid = $selected_cat3[0]['id'];
Header("Location:/cat-dashboard/cat-results/?catID=" . $myid
. "&question1=" . $_GET['question1'] . "&question2=" . $_GET['question2']
. "&question3=" . $_GET['question3'] . "&question4=" . $_GET['question4']
. "&question5=" . $_GET['question5'] . "&question6=" . $_GET['question6']
. "&question7=" . $_GET['question7'] . "&question8=" . $_GET['question8']);
This is the generated url:
/cat-dashboard/cat-results/?catID=&question1=0&question2=3&question3=1&question4=1&question5=1&question6=2&question7=1&question8=3
Am I doing something wrong? It doesn't show even if I use: $myid = "1";
I'm working on a simple script - file input which will change the site's background to the given image. It works, but my problem starts when I refresh site - the background image disappears.
I was wondering how to set and check if the background was set, so it will be there as long since next file input ?
I was trying to do that with a constant but does not work, here is my code:
if (isset($_POST['submit_bgImg'])) {
$myTarget = 'img/' . basename($_FILES['bg_img']['name']);
if (move_uploaded_file($_FILES['bg_img']['tmp_name'], $myTarget)) {
print('<style> body {background-image:url(img/' . $myFile . ');}</style>');
define('MY_BG', $_FILES['bg_img']['name']);
}
}
if (defined('MY_BG')) {
print('<style> body {background-image:url(img/' . MY_BG . ');}</style>');
}
any help ?
If you want to keep it only for the user you must store MY_BG variable in Session or Cookies like :$_SESSION['my_bg'] = $_FILES['bg_img']['name'];
if you want to keep it forever you must store it on a file or a Database like MySQL
$conn = new MySQLi('host','user','password','database name');
$conn->query("INSERT INTO table VALUES ('" . $bg_name . "')");
Try out with echo in php instead of print.I recommended to you can use ajax.
if (isset($_POST['submit_bgImg'])) {
$myTarget = 'img/' . basename($_FILES['bg_img']['name']);
if (move_uploaded_file($_FILES['bg_img']['tmp_name'], $myTarget)) {
echo "<style> body {background-image:url(img/' . $myFile . ');}</style>";
define('MY_BG', $_FILES['bg_img']['name']);
}
}
if (defined('MY_BG')) {
echo "<style> body {background-image:url(img/' . MY_BG . ');}</style>";
}
I am having trouble to dynamic the url using codeigniter.
I need to display dynamic URL look like below.
http://example.com/[store-url]
I did that. But when i try to view non-dynamic url like
http://example.com/blog. It accesssing store page only.
So i have wrote in my routes like below and it is working.
$route['blog'] = "blog";
But here my problem is i am having lot pages such as /blog. all pages are pointing the stores pages only including admin control panel
There any solution for that without setting the routes
In the routes.php
First wirte the coding of Dynamic URL
like
include_once (APPPATH . 'helpers/inflector_helper.php');
$path = explode('/', $_SERVER['REQUEST_URI']);
if ($_SERVER['HTTP_HOST'] == 'www.expample.com') {
$controller = $path[1];
} else {
$controller = $path[2];
}
$route[$controller] = plural($controller) . "/view" . ucwords($controller);
$route[$controller . '/list'] = plural($controller) . "/view" . ucwords($controller);
$route[$controller . '/view/(:num)'] = plural($controller) . "/view" . ucwords($controller) . "/$1";
$route[$controller . '/view/(:num)/(:any)'] = plural($controller) . "/view" . ucwords($controller) . "/$1/$2";
I write my static url
$route['login'] = "authenticate_user/index";
$route['validate'] = "authenticate_user/validateUser";
$route['logout'] = "authenticate_user/logout";
I hope this should work.
First lemme tell you what i am trying to achieve here . Suppose there is a url like this http://www.example.com/?id=12345 now what i want is if there is an id parameter available in the url i want to append the same parameter to every url on that page . Opencart has a url library that generates url i am sure you all must be familiar with it too , i found a way to do what i want but it's working at just some random parts of the website like categories url's are generating with id parameter appended to it and other's dont .
here's what i tried so far
File : System/libray/url.php
here's the function
public function link($route, $args = '', $connection = 'NONSSL') {
if ($connection == 'NONSSL') {
$url = $this->url;
}else {
$url = $this->ssl;
}
$url .= 'index.php?route=' . $route;
if ($args) {
$url .= str_replace('&', '&', '&' . ltrim($args, '&'));
}
foreach ($this->rewrite as $rewrite) {
$url = $rewrite->rewrite($url);
}
if(isset($_GET['id']))
{
if(!empty($this->request->get['id']))
$url .= '&id='.$this->request->get['id'];
if(!empty($_GET['id']))
{
$url .= '&id='.$_GET['id'];
}
}
return $url;
}
The problem is that not everything uses this method to generate its URLs.
For example, anything to do with banners (e.g. the Carousel module) uses links that the admin sets manually in System->Design->Banners, so you would also need to edit the code for this too. The simplest and probably the correct way is to edit the data that the models spit out e.g.
model_design_banner->getBanner() becomes
public function getBanner($banner_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "banner_image bi LEFT JOIN " . DB_PREFIX . "banner_image_description bid ON (bi.banner_image_id = bid.banner_image_id) WHERE bi.banner_id = '" . (int)$banner_id . "' AND bid.language_id = '" . (int)$this->config->get('config_language_id') . "'");
if (isset($_GET['id'])) {
array_walk($query->rows, function(&$value) {
$value['link'] .= '&id=' . $_GET['id'];
});
}
return $query->rows;
}
It's either that, or edit the output in every single controller that uses this method.
That's just an example for banners, though. I don't recall off-hand which other modules will need to be edited, but if there's a particular one that's making you scratch your head, let me know and I'll give you another example to fix it.
in following function
public static function ToDepartment($departmentId, $page = 1)
{
$link = self::CleanUrlText(Catalog::GetDepartmentName($departmentId)) .
'-d' . $departmentId . '/';
if ($page > 1)
$link .= 'page-' . $page . '/';
return self::Build($link);
}
there is a line
$link = self::CleanUrlText(Catalog::GetDepartmentName($departmentId)) .
'-d' . $departmentId . '/';
I want to know will self:CleanUrlText() will be evaluated first or Catalog:GetDepartmentName will be evaluated first
if Catalog:GetDepartmentName is evaluated first then, I have a confusion,
what purpose does URL cleaning solve,
if I am visiting a page such as http://localhost/tshirtshop/visit###-the-zoo-d2/
then .htaccess is handling the URL ReWriting part,
where d2 will get converted to DepartmentId=2 and internally in all code logic I will use DepartmentId which is an INT , then why CleanURL function is required
The code is given here
1st: Catalog::GetDepartmentName
2nd: self::CleanUrlText