conditional-statements

Wordpress conditional statements for taxonomy, term, inside a loop not working

六眼飞鱼酱① 提交于 2019-12-04 22:25:52
This is such a basic problem I'm having but I've tried so many different functions and can't get any to work. On my wordpress website I have created a taxonomy called ' file-formats ' and in this taxonomy I have created these terms (I think these are terms?)... PDF , MOV , PPT and DOC See screenshot below... The problem I have which I can't seem to figure out, is I have a simple WP_Query loop, see below... <?php $downloads = new WP_Query(array( 'post_type' => 'downloads', 'order' => 'ASC', 'posts_per_page' => -1 )); ?> <?php if ($downloads->have_posts()) : ?> <?php while ($downloads->have

Dynamically changing conditions of an if statement in C#

蹲街弑〆低调 提交于 2019-12-04 21:00:49
I'm working on an algorithm whose purpose is to create a collection of dates on which a certain event occurs (so that I can bold them on a MonthCalendar control, or display them in some other way). Now, for simple time intervals that can be described with regular functions (for instance if the event occurs every Monday or every 10 days) this is not a problem. The real problem occurs when I have an event with irregular occurrences (for instance if event occurs every Friday if the first day of the month is Tuesday and that kind of events). Since I can't predict the format of that condition's, or

rails - find with condition in rails 4

故事扮演 提交于 2019-12-04 20:35:56
I recently upgraded my rails to Rails 4.1.6. This query used to work : @user = User.find(:all, :conditions => { :name => 'batman' }) Now I get this error message: Couldn't find all Users with 'id': (all, {:conditions=>{:name=>"batman"}}) (found 0 results, but was looking for 2) When I check the logs I can see that rails is trying to do a completely different query : User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" IN ('all', '--- :conditions: :name: batman ') It looks like, it's trying to get all the users with the id "all" and "{:conditions=>{:name=>"batman"}}". Please help.

Rails associations: How do I limit/scope a has_many :through with multiple self-referencing conditions?

这一生的挚爱 提交于 2019-12-04 19:40:56
What's the best way to do this? I'm trying something like this, but it feels... wrong. (NOTE: It's all about the :conditions in the has_many association...) class Submission < ActiveRecord::Base belongs_to :checklist has_many :jobs, :through => :checklist, :source => :job, :conditions => ["jobs.archived = false OR jobs.archived_at > #{self.created_at} OR jobs.created_at < #{self.created_at}"] end Rails 3.2.11, Ruby 1.9.3 What I'm trying to do I need to pass multiple conditions on a has_many :through association and refer to the "self" model to do comparisons in those conditions. I've found

Magento - check if cms page

回眸只為那壹抹淺笑 提交于 2019-12-04 19:33:02
问题 i want to check via php if a page is a cms_page in Magento. I need diffrent breadcrumbs for cms pages, so im trying to this with a condition, but i have no idea how to or where to look at. Heres my breadcrumbs.phtml so far. <?php if(this is a cms page): ?> <p>some content</p> <?php else: ?> <?php if($crumbs && is_array($crumbs)): ?> <div class="breadcrumbs"> <ul> <?php $charsges = 0; ?> <?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?> <?php $charsges = strlen($_crumbInfo['label']) +

Exclude click event based on condition?

断了今生、忘了曾经 提交于 2019-12-04 19:01:40
问题 I'm trying to set conditions on a jQuery event. I have an input element and a div. I want to detect a click anywhere on the page and to execute that method but only if the click is not on the input or div. 回答1: Use the jQuery click() or live() functions and then check the target of the click event using the jQuery is() function. bind click event on document if the target is not input or div continue . $(document.body).click(function(e) { if( !$(e.target).is("input, div") ) { console.log("Run

Is there an sql condition that can look for non integers in a column?

[亡魂溺海] 提交于 2019-12-04 17:13:52
问题 Basically I would like a select statement that would function like this SELECT * FROM table WHERE column IS NOT INT Is there a condition like this or how do you check for non-integers in an nvarchar(10) column? 回答1: In SQL Server you can do: SELECT * FROM mytable WHERE CASE WHEN IsNumeric(mycolumn) = 1 THEN CASE WHEN CAST(mycolumn AS FLOAT) <> CAST(CAST(mycolumn AS FLOAT) AS INT) THEN 1 END ELSE 1 END = 1 回答2: You could also use SELECT * FROM T WHERE C = '' OR C LIKE '%[^0-9-]%' /*Contains a

Conditional inner join statements in MySQL

纵然是瞬间 提交于 2019-12-04 16:39:28
Is there a way I can conditionally change which table i'm inner joining on based on the value of a field in another table? Here's what I got so far (but it errors) out: SELECT j.jobID, j.jobNumber, CASE WHEN j.idType = 'dealership' THEN d.dealershipName WHEN j.idType = 'Group' THEN g.groupName WHEN j.idType = 'Agency' then a.agencyName END as dealershipName, CASE WHEN p.manualTimestamp != '0000-00-00 00:00:00' THEN UNIX_TIMESTAMP(p.manualTimestamp) WHEN p.manualTimestamp = '0000-00-00 00:00:00' THEN p.timestamp END as checkTS, CONCAT_WS(' ', ui.fName, ui.lName) as salesRep FROM jobs j LEFT

R - vectorised conditional replace

↘锁芯ラ 提交于 2019-12-04 16:29:28
Hi I'm trying manipulate a list of numbers and I would like to do so without a for loop, using fast native operation in R. The pseudocode for the manipulation is : By default the starting total is 100 (for every block within zeros) From the first zero to next zero, the moment the cumulative total falls by more than 2% replace all subsequent numbers with zero. Do this far all blocks of numbers within zeros The cumulative sums resets to 100 every time For example if following were my data : d <- c(0,0,0,1,3,4,5,-1,2,3,-5,8,0,0,-2,-3,3,5,0,0,0,-1,-1,-1,-1); Results would be : 0 0 0 1 3 4 5 -1 2 3

How do I do a MSBuild Condition testing if an ItemGroup contains an item?

点点圈 提交于 2019-12-04 16:23:58
问题 This should be simple, but I can't find how to do this (or maybe it's not possible). In MSBuild I have an ItemGroup that is a list of files. I want to execute a task only if a particular file is in that ItemGroup Something like: <Copy Condition="@(Files) <contains> C:\MyFile.txt" .... /> Any way to do this? Preferably without writing a custom task. Edit: The list of files is only to do with the condition. Otherwise it has no relation to the task. 回答1: Try <Copy Condition="'%(Files.Identity)'