I am using smarty and have a fairly simple question that I just don't know the correct terminology to find the answer for.
I am trying to make so that my meta description is a combination of two variables.
{$product.descr|cat:" Learn More about:"|cat:$product.fulldescr}
The above code works, but I need to use the "|replace" function on the second variable but not the first one.
So, I think I would want something like this:
{assign var='fulldescr-changed' value=$product.fulldescr|replace 'x':'y'}
{$product.descr|cat:" Learn More about:"|cat:$fulldescr-changed}"
This does not work though and I am not sure what I am doing wrong. Any thoughts would be appreciated.
You forgot a colon after replace. Also I would not use a hyphen in the name of the variable:
{assign var='fulldescr_changed' value=$product.fulldescr|replace:'x':'y'}
Related
I have found a script to set the background image and do some more stuff, but that's not important.
Look at this line, it's supposed to set a route, nothing complicated.
#!/bin/sh
bgloc="${XDG_DATA_HOME:-$HOME/.local/share/}bg"
I didn't understand what was it doing, because of the env variable and the :- that comes after it. Now, after some trial and error, I've figured it out. It sets the variable bgloc with the value of that env variable and, if that variable is not set —which is the case—, then, it use the route that comes after the :- .
So, the question is: why does that happen? I mean, I've searched it on the internet, and I haven't found anything. Is it supposed to work like this? In that case, where can I find information about that? I'd like to learn more about it, but I don't find any information on the internet. Some help would be great. Thanks.
A lot can be done with values within ${} in bash.
To find out more about these features I would recommend to read TLDP manual on this topic.
I'm looking for a way to include code as part of a paragraph in DokuWiki like I can by adding backtick escapes in StackOverflow like _so_. Simply adding <code>bla</code> puts code on it's own line.
You probably want to use ''%%here is code%%''. This formats it in monospace ('') and prevents any interpretion of possible wiki markup (%%).
I was able to find an answer to my own question. Add quotes around the in-text code ''like this''. Simple, short, and works great.
I,m using Builder::XmlMarkup to create xml. I want to create a tag without content because the api force me to create this.
If I use a blog
xml.tag do
end
I get what i need
<tag></tag>
but I want it shorter
xml.mytag
this gives me
<mytag/>
but i want
<mytag></mytag>
what do I have to pass as option.
regards Kai
Just pass empty string as a parameter. xml.mytag('')
Why do you want <mytag></mytag> instead of <mytag/>? Since the output is XML, downstream applications should not know or care about the difference.
According to the Infoset spec (Appendix D point 7), "The difference between the two forms of an empty element: <foo/> and <foo></foo>" is not represented in the XML Information Set.
This doesn't answer your "how" question, but if you discover that you actually don't need to do what you're trying to do, it may save you from a difficult and unnecessary wild goose chase.
ok empty string is nice, another one-line-way is empty block I found out.
xml.mytag{}
I've got a situation where I need to alter the contents of a cached file based off of one of the query string arguments passed in. I'd love to use sed to do a simple regular expression replacement of a value based off of said argument but I can't figure that one out. I could use a ruby script to do the replacement for me but can't seem to access the query string for the request within the script. The documents for mod_ext_filter say:
In addition to the standard CGI environment variables, DOCUMENT_URI, DOCUMENT_PATH_INFO, and QUERY_STRING_UNESCAPED will also be set for the program.
Um yeah, can't seem to access those.
Has anybody any experience with this or does anybody have a better solution?
Doh! Looks like I simply need to access the ENV variable within ruby. Pretty dumb of me.
Using PHP scripting language server function we can able to get the query string values.
echo $_SERVER['REQUEST_URI'];
And pass the URL arguments as a variable to the file and make it dynamic.
Refer : PHP.net
In the path:
Format: http://mydomain.com/{category}/{subcategory}/{pageNumber}/{pageSize}
Example: http://mydomain.com/books/thriller/3/25
In the querystring:
Format: http://mydomain.com/{category}/{subcategory}? pageNumber={pageNumber}&pageSize={pageSize}
Example: http://mydomain.com/books/thriller?pageNumber=3&pageSize=25
I like having everything on the path, but my problem with that is that while it is obvious (or at least somewhat obvious) what "books" and "thriller" are in first example, the "3" and "25" seem pretty arbitrary by contrast.
Is there a canonical method for determining what goes where in MVC, or is it really just up to the dev?
I prefer things like pagenumbers to be in the querystring variables. I think there's a difference in descriptiveness between
http://mydomain.com/books/thriller?pagesize=50&page=4
and
http://mydomain.com/books/thriller/50/4
The point (to me) of having clean url's is for them to be more descriptive and readable, and I find the first example to be just that.
One interesting point made byJohnRudolfLewis is:
One rule of thumb that I follow is
that if the argument is required,
consider using the path, if the
argument is optional, always use
querystring arguments.
One rule of thumb that I follow is that if the argument is required, consider using the path, if the argument is optional, always use querystring arguments.
Overall, I'd stick to whatever makes the url look more readable.
This site puts it in the querystring: https://stackoverflow.com/questions?page=2&pagesize=30
Well, it's obviously up to you. But, you're designing a RESTful interface that's supposed to be human readable. The querystring is much better in that regard. Otherwise you're looking at two numbers that could really be anything. And who's going to remember the order?
Is there a canonical method for determining what goes where in MVC, or is it really just up to the dev?
It's up to you.
MVC is about the organization/flow of your server-side code and seperating the view from the business layer, not so much about query parameters.
You could also consider the following
Format
http://mydomain.com/{category}/{subcategory}/page/{pageNumber}/results/{pageSize}
Example
http://mydomain.com/books/thriller/page/3/results/25
It is pretty much up to the dev. I would say put the pageSize in the URL.