I'm parsing some feeds using simplepie, I have an array with multiple rss urls, and I am storing it in the database. Along with the url I am also trying to store the get_title() which is like the source name. The problem is some feeds do not specify this so it's blank, as a result it's not storing in the database.
This is what I do to get the title:
$feed = $item->get_feed(); $sourcename = $feed->get_title();
I wondered if i could specify a default get_title as I know the names already, so something like:
$feed->set_feed_url(array('http://www.example.com/feed'=>'Example Feed',
'http://exampletwo.com/rss'=>'Example Two Feed')
Is it possible something like above or similar, perhaps I can avoid doing a condition and use something built it?
Related
My task is the following, I need a way to store a query string value of s and pass it to the merchants Order Confirmation email.
consider the following,...mybigcommerce.com?s=fb.
Let's say that my client posts his website link to facebook and adds in a query string of s with a value of FB (facebook).
The desired result would be that on the initial load of the page, the query string would be saved as a cookie(or in Bigcommerce's case a global or store front variable)
Once I have it saved, I now know that you just simply append the variable to the email template.
example output:
email template source : %name_of_variable%.
My problem is, however, I don't see how to store the value into a variable.
Can I accomplish this without using the API, or for that matter can I do this using the API?
Thank you in advanced, I hope I have provided enough information.
Unfortunately, you cannot create your own variable in the email templates. The variables used here have been created and are supported by code within the core application. As such, it would require a core application change to extend existing functionality/add a variable. There isn't a way for you to write to an existing variable either.
I am trying to pass this into a custom field called "_vtprd_includeOrExclude"
a:2:{s:23:"includeOrExclude_option";s:11:"includeList";s:29:"includeOrExclude_checked_list";a:2:{i:0;s:2:"1856";i:1;s:4:"1857";}}
I am using WPAllImport to get the data out of an XML package and into the field.
I know that the function works because if I put "bob" in the custom field it goes in without any issue.
What is wrong with this string that is causing it to come up empty?
As always, your feedback and help is greatly appreciated.
The problem was that the data within the string would fail if turned into an array because the string count was incorrect for one of the fields.
The part to look at is at the end.
... a:2:{i:0;s:2:"1856";i:1;s:4:"1857";}}
The offender is i:0;s:2:"1856"
"1856" is 4 string characters long, not to.
So it SHOULD look like this.
i:0;s:4:"1856"
When I made that change I silenced the custom function and it worked just fine.
Perfect example of not knowing enough about how this structure works. So I guess knowing is half the battle.
go joe.
Looking at this
http://www.dotnetperls.com/ashx
I might have bits of code like this:
string file = context.Request.QueryString["file"];
if (file == "logo")
{
r.WriteFile("Logo1.png");
}
else
{
r.WriteFile("Flower1.png");
}
That should allow me to see different things depending on URL that I enter in a browser, for example:
http://www.dotnetperls.com/?file=logo
http://www.dotnetperls.com/?file=sth_else_eg_flower
The problem I am facing now is how, knowing just http://www.dotnetperls.com/?file can I read what the all the assumed options of the file variable are? In this case it would be "logo" and anything else.
What I have in reality is http://www.somewebstie.com/somefile.ashx?somevariable=. I can Google up the string to get few results (i.e. http://www.somewebstie.com/somefile.ashx?somevariable=abcde or http://www.somewebstie.com/somefile.ashx?somevariable=xyz) thus I know it exists and is somehow searchable. I just would like to know all the other "abcde" and "xyz". If I try just http://www.somewebstie.com/somefile.ashx I get a singe line error saying that I am giving a wrong variable and I cannot see anything important in the source of the site.
What might be important here - I have zero knowledge about web technologies.
You can't get this information. Its all hidden in the code implementation. There is no published format (by default) that will show you all of the available options the code is looking for.
I am trying to find entities (Tags) in the database via their Name property, where it is important to ignore the case (When database is searched and the Database contains a Tag with the name Database, that one should be returned). Right now, my code looks like this:
public IEnumerable<db.Tag> FindByNames(IEnumerable<string> tagNames)
{
return this.DatabaseContext.Tags
.Where(tag => tagNames.Contains(tag.Name));
}
Obviously, this one is case sensitive. I have tried to provide StringComparer.OrdinalIgnoreCase as comparer to the Contains method, but got a warning during execution that the expression could not be translated and would be executed in code rather than in the database (I don't remember the exact message, I will edit as soon as I am back on my development machine). I can live with that if I have to, but it would be nice to know how to let the database do the work in this case. Is it possible?
No change should be necessary. SQLite's "LIKE" is already case-insensitive.
The default behavior of the LIKE operator is to ignore case for ASCII characters.
(cref https://www.sqlite.org/pragma.html#pragma_case_sensitive_like and Case sensitive and insensitive like in SQLite)
Of course, you can always use .FromSql() to get the exact query you want. Example:
context.Tags.FromSql("SELECT * FROM tags WHERE name LIKE '%{0}%'", tagName)
I am having trouble with passing variables in my wordpress url. When i pass the variable and the value to the url, all is well
i.e.
mysite.com/product-part/?part=1/
but what i want is for the variable to be passed as follows:
mysite.com/product-part/1
In php, the normal way to pass variables to a url is:
mysite.com/?id=1
In wordpress, the above would look like this:
mysite.com/1
How can I achieve the above?
The Rewrite API lets you add create custom rewrite rules inside WordPress. You can call add_rewrite_rule() inside the "init" hook and give it a regular expression to translate into a query string. Something like:
function setup_rewrite_rules() {
add_rewrite_rule('^store/([0-9A-Za-z]+)/([0-9]+)/?', 'index.php?product_slug=$matches[1]&part=$matches[2]', 'top');
}
add_action('init', 'setup_rewrite_rules');
Note that the URL isn't an exact match for the existing product URLs because you need something that matches this regular expression.
You'll probably need to use a template_redirect handler to detect when these variables are set and show the normal product page since you're not using the product's normal permalink.
This is a very, very bad way to pass a variable. Wordpress uses "re-write" rules to determine what query to run. These "permalinks" identify, for instance, what post your are going to. In your example, using an integer such as "1", you could pass a variable by writing a re-write rule that said something like "all integers are a variable", or "all slugs that start with an integer are a variable" but you would soon get into conflicts with post names. What about posts that start with numbers, for instance? Also, many plugins would use permalinks to send you to certain pages, and you could come into conflict there. Better to use any of these things to pass variables:
get variables
post variables
hidden post variables
session variables
nonces
Wordpress meta-data like user meta data
Good luck