smarty , how to solve smarty incompatible - smarty

unrecognized tag: $ncache['tab']="gallery_cat" (Smarty_Compiler.class.php, line 455)
i got this error, when i type the following code
{$ncache[tab]="gallery_cat"}
{$ncache.tab="gallery_cat"}
anyway to assign an array in smarty?

You can assign arrays in smarty with the php tag like this:
{php}
$this->assign("array", array('1','2','3'));
{/php}
Or if you are using version 3 you can also use it directly from smarty
{$array = ['1','2','3']}

Related

Put one dinamic object with assets in laravel

Hi i dont know how put img with assets.
I have this
{{asset('Articulos/{{$Articulo->path}}')}}
but i have error
syntax error, unexpected '}'
can you help me?
The correct syntax is:
{{ asset('Articulos/' . $Articulo->path) }}

codeigniter array session issue after move site one server(godaddy) to another server(bluehost)

There is issue in session. This is my array.
print_r($this->session->userdata("user_data"));
Array
(
[useremail] => myid#gmail.com
[user_id] => 1
[is_login] => 1
)
I want to get the useremail . so I am writing this code.
print_r($this->session->userdata("user_data")['useremail']);
It gives the error . Parse error: syntax error, unexpected '['
If I am writing the code like this :
$dataval = $this->session->userdata("user_data");
print_r($dataval['useremail']);
Then it it working fine .
Please help me what is issue ?
It is because you (probably) moved from newer php version (5.4+) to older version (5.2).
Accessing array items directly by calling function name is only available on php 5.4 and newer: array dereferencing.
Only solution is to use temporary variable (like your $dataval). Or you can switch to newere php version, if the bluehost allows it.

Undefined Variable Errors

I receive a lot of undefined variable errors in zend studio 10.
I have a php file like this :
file var.php
<?php
$functions = $root."/requires/functions.php";
$top_utf = $root."/requires/top_utf.php" ;
$database = $root."/requires/db.php" ;
$footer = $root."/requires/pageFooter.php" ;
?>
Now if I use the following code in a php file, zend studio shows Undefined Variable errors on all the require_once lines. (If I access this page with a browser the page is displayed as expected and it works perfectly.)
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
require_once($root."/requires/vars.php") ;
require_once($functions);
require_once($top_utf);
require_once($database);
require_once($footer);
?>
Doesn't Zend Studio recognize the declared variables in an included file (var.php in this case)?
Since $functions and $top_utf variables are defined in var.php, I believe I shouldn't receive these errors.
Any kind of advice is much appreciated.
If you're going to use this style of programming, which I'm not advocating, I suggest you define constants in your var.php instead

Can I use regular expressions with guard-concat?

I'm using the guard-concat plugin for guard to concatenate my handlebar template files.
Can I use regular expression to make it concat all files in one folder instead of typing in all the names of the files?
so instead of doing this:
guard :concat, type: "php", files: %w(a b b/c b/d), input_dir: "app/views/handlebars", output: "app/views/handlebars/all"
I could do this:
guard :concat, type: "php", files: %r{.+}, input_dir: "app/views/handlebars", output: "app/views/handlebars/all"
When I do that I get the following error:
ERROR - Invalid Guardfile, original error is: > [#] undefined method `join' for /.+/:Regexp
Francesco Canessa (responsible for guard-concat) has told me
I can implement this feature but usually the files order is important
both for CSS and JS (for example for code that needs libraries to be
loaded first)
So this is not possible today but might be added in future releases.
link to the issue on guard-concat github page
You can use Dir#glob (or it alias Dir#[]):
Dir['*/**.php']
as argument. It will return array containing all files with .php extension in all subfolders.

VIM syntax highlighting of html nested in yaml

Given a yaml file that contains html, like this:
template : |+
<div>Hello, world</div>
Is it possible in Vim (version 7.3.087) to highlight the html portion with html syntax highlighting?
I found the post Different syntax highlighting within regions of a file, which seems to have exactly the concept I was looking for, but I cannot get it to work as expected with yaml. I'd expect to be able to do the following (as suggested in the link):
" .vimrc
" include the code from the above link
call TextEnableCodeSnip('html' ,'#{{{html' ,'#html}}}', 'SpecialComment')
Then have the yaml as, for example:
template : |+ #{{{html
<div>Hello, world</div>
#html}}}
Unfortunately this does not work as expected i.e. the html code remains entirely highlighted with yaml. I've also noted that with my configuration (MacVim 55), this doesn't work in text files either.
I'd be grateful for your thoughts or suggestions, and thank you for reading.
check out my related question: Trouble using Vim's syn-include and syn-region to embed syntax highlighting. There I am trying to embed Python within TeX, but I think the solution might work for your case, too.
I think you want to do something like this:
let b:current_syntax = ''
unlet b:current_syntax
runtime! syntax/yaml.vim
let b:current_syntax = ''
unlet b:current_syntax
syntax include #YaML syntax/yaml.vim
let b:current_syntax = ''
unlet b:current_syntax
syntax include #HTML syntax/html.vim
syntax region htmlEmbedded matchgroup=Snip start='#{{{html' end='#html}}}' containedin=#YaML contains=#HTML
hi link Snip SpecialComment
let b:current_syntax = 'yaml.html'
The block with the runtime! command might be unnecessary if your YaML is already highlighted.
You could try to add the following in your .vimrc:
autocmd BufRead,BufNewFile *.yaml setfiletype html.yaml
A yaml file will be considered to be both of type yaml and html and both syntax color scheme should be applied but I don't really know how conflicts between the two schemes are dealt with...
It looks like you want to move the start pattern to the beginning of the next line:
template : |+
#{{{html
<div>Hello, world</div>
#html}}}
More details:
I'm on WinXP, but I saw almost the same behavior that you described.
When in a file with filetype yaml, after calling TextEnableCodeSnip I didn't see a change until I moved the start pattern down the the beginning of the next line. I was able to see the syntax highlighting work in a file with no filetype though, so this still a chance this won't work for you.
I used Maxy-B's solution. My code, in particular, is a bit different so I thought to post it for posterity:
~/.vim/after/syntax/yaml.vim
let b:current_syntax = ''
unlet b:current_syntax
syntax include #HTML syntax/html.vim
syntax region htmlCode start=#^html:#hs=e+1 end=+^\w+he=s-1,me=s-1
\ contains=#HTML
let b:current_syntax = ''
unlet b:current_syntax
syntax include #TEX syntax/tex.vim
syntax region texCode start=#^tex:#hs=e+1 end=+^\w+he=s-1,me=s-1
\ contains=#TEX
This highlights the top-level YAML nodes html and tex with those respective types of code. It's not very dynamic, but it suits my purpose and this may serve as helpful guideline for someone doing something similar. It'll highlight the following as expected (or at least, as I expect it), for example:
regular: # yaml
- yaml # yaml
html:
<b>hello</b> # html
tex:
\begin{document} # tex
\end{document} # tex
the-end: may be necessary # yaml

Resources