conditional-statements

Magento - check if cms page

天涯浪子 提交于 2019-12-03 12:41:19
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']) + $charsges; if($charsges > 40){ $chars = 18; if(strlen($_crumbInfo['label']) > $chars){ $_crumbInfo['label'

Exclude click event based on condition?

ⅰ亾dé卋堺 提交于 2019-12-03 12:38:02
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. 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 function because image or div were not clicked!"); } }); Example webpage => http://mikegrace.s3.amazonaws

Jquery “if this and if that” then do this

僤鯓⒐⒋嵵緔 提交于 2019-12-03 12:22:01
This should be so simple, but it's not working for me. I want to say: If this doesn't have the class "current" AND if the body class does not equal "home", then do this.... Here is what I'm trying (among other things) to no avail. Only the first conditional works. $(".nav1 > ul > li").mouseleave(function() { if ( (!$(this).hasClass("current")) || (!$(body).hasClass("home")) ){ $(this).find(".nav-overlay").show(); } }); What am I doing wrong? Thank you! UPDATE FOR CLARITY: I only want to show ".nav-overlay" when the following conditions are true: You are not on the homepage (body class="home")

If…Then…Else with multiple statements after Then

穿精又带淫゛_ 提交于 2019-12-03 12:03:02
问题 a very easy question: considering an If...Then...Else instruction in VBA, how can I separate multiple instructions after Then ? In other words, should I write something like If condition [ Then ] [ statement1 ] & [statement2] Else [Else statement] (i.e. using "&"), or If condition [ Then ] [ statement1 ] And [statement2] Else [Else statement] (i.e. using "And"), or some other separator/command? 回答1: Multiple statements are to be separated by a new line: If SkyIsBlue Then StartEngines Pollute

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

我只是一个虾纸丫 提交于 2019-12-03 10:34:11
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? 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 You could also use SELECT * FROM T WHERE C = '' OR C LIKE '%[^0-9-]%' /*Contains a char other than - or 0-9*/ OR C LIKE '_%-%' /*Contains the - char other than 1st position*/ 来源: https:/

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

亡梦爱人 提交于 2019-12-03 10:30:53
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. Try <Copy Condition="'%(Files.Identity)' == 'C:\MyFile.txt'" .. /> 来源: https://stackoverflow.com/questions/7594366/how-do-i-do-a-msbuild-condition

how to use “if” statements inside pipeline

╄→尐↘猪︶ㄣ 提交于 2019-12-03 08:58:36
问题 I'm trying to use if inside a pipeline. I know that there is where (alias ? ) filter, but what if I want activate a filter only if a certain condition is satisfied? I mean, for example: get-something | ? {$_.someone -eq 'somespecific'} | format-table How to use if inside the pipeline to switch the filter on/off? Is it possible? Does it make sense? Thanks EDITED to clarify Without pipeline it would look like this: if($filter) { get-something | ? {$_.someone -eq 'somespecific'} } else { get

Dynamic Or Clause Linq

最后都变了- 提交于 2019-12-03 08:12:23
Today we currently have a statement like this: var Query = (from dp in db.Patients select dp); var UserID = User.Identity.GetUserId(); if (User.IsInRole("Administrator")) { Query = Query.Where(x => x.AdministratorID == UserID); } if (User.IsInRole("Counselor")) { Query = Query.Where(x => x.CounselorID == UserID); } if (User.IsInRole("Physician")) { Query = Query.Where(x => x.PhysicianID == UserID); } The problem is we have Users that can have multiple roles. If a User is both an Counselor and Physician we want the system to pull back all patients where CounselorID == UserID or PhysicianID ==

Simple C++ input from file…how to?

邮差的信 提交于 2019-12-03 08:01:49
问题 I have a file: P 0.5 0.6 0.3 30 300 80 150 160 400 200 150 250 300 T r 45 0 0 s 0.5 1.5 0 0 t 200 –150 . . . When I read in 'P' I know that 3 floats will follow. That will be followed by a finite number of X and Y coordinates. The number will vary until a 'T' is reached which I have to recognize. Then there could be an 'r', 's' or 't' followed by some values. Anyways I know how to recognize 'P' and then take in the 2 floats but then I know I have to have a while loop for the X and Y

In a “for” statement, should I use `!=` or `<`?

泄露秘密 提交于 2019-12-03 07:21:05
问题 I've seen both of these two for statements: for(i=0;i<10;i++) for(i=0;i!=10;i++) I know they all stop when i reaches 10 , but it seems better to use the second one (I heard). What is the different?I also want to know when use iterator to access member of a vector, what is the difference between iterator condition < vec.end() and != vec.end() 回答1: for(i = start; i != end; ++i) This is the "standard" iterator loop. It has the advantage that it works with both pointers and standard library