if([node:term] == "Main Stage Theatre"){return TRUE;}
First I have a condition that checks the node creation of an Event.
Now, this second condition i want to check the taxonomy terms, and if it is the right one it will add to the my node queue.
my above piece of code I don't think is correct. Can someone help me with the check a truth value feature?
Your code looks correct, did you include PHP tags? You have to wrap your code in <?php ?> tags in the Truth value textfield.
I have this working with:
<?php if ('[node:term]' == 'Comedy') { return TRUE; } else { return FALSE; } ?>
Note: If you are allowing multiple terms to be selected for an Event node, [node:term] only returns the "top" term.
For that kind of comparison I suggest using "text comparison"; it compares two text fields and evaluates TRUE if the two fields match. You could use a "token" (e.g. [node:term] in your example) in one field and text (e.g. Main Stage Theatre) in the other field. You can also check a box to return true if the two fields do not evaluate as equal and there is another checkbox option to use Regex for the match comparison. I just used it to check the language of the content a comment was left on.
Related
I have two editor instances.
One is editable
Second one is read only for preview what user is typed
I'm copied editor state beetwen those editors - wtih no problems
But i want to hide second editor when first one is empty. I'm trying something like this but it always return false
...
function onChange(editorState) {
console.log(editorState.isEmpty())
}
function Editor() {
...
return (
<>
<LexicalComposer initialConfig={editorConfig}>
<ToolbarPlugin />
<RichTextPlugin
contentEditable={<ContentEditable className="editor-input" />}
placeholder={<Placeholder />}
ErrorBoundary={LexicalErrorBoundary}
/>
<OnChangePlugin onChange={onChange} />
<LexicalComposer />
)
}
There are, unfortunately, currently several different ways to do this, depending on exactly what you mean by "empty". You can us EditorState.isEmpty, but this is checking to see if the _nodeMap contains only a single node (the root) and the selection is null - so it's really about emptiness in the sense that the EditorState is in the same state it would be in had it just been initialized. However, this is might not be what you want - usually a visually empty editor will have a RootNode with a single ParagraphNode child, and you may or may not care if the Selection is null. So, you could look at using ElementNode.isEmpty:
$getRoot().isEmpty()
This checks if the RootNode has 0 children. Once again, in a typical editor, that might return false in a lot of cases where you would expect it to return true (like if the editor is initialized with an empty ParagraphNode under the RootNode). So, you could do:
const root = $getRoot();
const isEmpty = root.getFirstChild().isEmpty() && root.getChildrenSize === 1
However, this wouldn't account for whitespace - which you might also care about. If you want to consider an editor with only whitespace as empty, then you might want to use $isRootTextContentEmpty from #lexical/text. You can also look at the implementation of this function to see how you might go about tweaking it for your use case.
I want to give users the ability to sort posts themselves using some filter links on the side, so for instance:
To sort by title: www.example.com/?orderby=title&order=asc
To sort by date: www.example.com/?orderby=date&order=asc
So I want to be able to sort posts using a custom field called "shares" that returns a number , and I use Advanced Custom Fields plugin to generate that field, but not sure how I can generate such query and more importantly, giving a link to apply it if possible.
thanks in advance.
Try this simple code and after making sure that it works, you need to improve it yourself (adding conditions f.e.)
add_action('pre_get_posts','order_post_filter');
function order_post_filter($query){
//then you will need to add some condition here
if (isset($_GET["orderby"]) and isset($_GET["order"])){
$order=$_GET["order"]=='DESC'?'DESC':'ASC';
$query->set('order',$order);
if ($_GET["orderby"]=='date'){
$orderby='date';
}
elseif ($_GET["orderby"]=='title'){
$orderby='title';
}
else {
$query->set('meta_key',$_GET["orderby"]);
$orderby='meta_value';
}
$query->set('orderby',$orderby);
}
}
When I use md-autocomplete, the filter is applied to the second last keypress and not to the current one. I tried different options for filtering but I'm stuck and don't know how to integrate my Meteor collection with md-autocomplete.
In my controller component, I have the filter logic implemented like this:
this.searchText = '';
this.subscribe('people');
this.helpers({
people() {
return People.find({
name: {
$regex: `${this.getReactively('searchText')}.*`,
$options: 'i'
}
});
}
});
my template looks this way:
<md-autocomplete
md-selected-item="ctrl.selectedItem"
md-search-text="ctrl.searchText"
md-items="person in ctrl.people"
md-item-text="person.name"
md-min-length="0"
placeholder="Who should be selected?">
<md-item-template>
<span md-highlight-text="ctrl.searchText" md-highlight-flags="^i">{{person.name}}</span>
</md-item-template>
<md-not-found>
Nobody found matching "{{ctrl.searchText}}".
</md-not-found>
</md-autocomplete>
The filter works beside the problem, that the last key ob my searchText is not applied to filter the list.
Example: I have the people "Till", "Tony" and "Andy" in my collection. when I type "T", nothing is filtered out at all, but the T from Till and Tony is highlighted correctly on my list.
When I type "Ti", Till and Tony stay in the list and Andy is filtered out. The "Ti" of Till is highlighted. So the highlight works as expected, but the filter does not apply to the last letter I typed.
I would be glad for some hints, how to apply my searchText correctly to md-autocomplete. I was searching for my mistake for hours now, without success.
Is it possible to define a new operation for a node access?
As I know, the operations for a node that are used in hook_access() are:
create
delete
update
view
I have a custom content type for which I need another operation, such as "suggest."
short answer is NO as node_access() who is responsible to call hook_access() does a check
on the $op parameter
if (!$node || !in_array($op,
array('view', 'update', 'delete',
'create'), TRUE)) {
return FALSE; }
you can attach some extra info to the node object in your suggest() function - hopefully called before node_access() - then check these extra informations in your hook_access() and return TRUE/FALSE according.
another option consists in hardcode permission checks into the suggest() action itself without messing around with hook_access.
Though I don't doubt this has been answered I cannot find a great match for my question.
I have a table for which I'd like to filter rows based on whether or not they contain a hidden field matching a value.
I understand that the technique tends to be "show all rows", "filter the set", "show/hide that filtered set"
I have the following jquery but I'm aweful with filter and my filtered set seems to always contain no elements.
my table is the usual
<table>
<tr><td>header></td><td> </tr>
<tr>
<td>a visible cell</td><td><input type='hidden' id='big-asp.net-id' value='what-im-filtering-on' />
</td>
</tr>
</table>
My goal is to be able to match on tr who's descendent contains a hidden input containing either true or false.
this is how I've tried the selector (variations of this) and I'm not even testing for the value yet.
function OnFilterChanged(e){
//debugger;
var checkedVal = $("#filters input[type='radio']:checked").val();
var allRows = $("#match-grid-container .tabular-data tr");
if(checkedVal=="all"){
allRows.show();
}
else if(checkedVal=="matched"){
allRows.show();
allRows.filter(function(){$(this).find("input[type='hidden'][id~='IsAutoMatchHiddenField']")}).hide();
}
else if(checkedVal=="unmatched"){
}
}
Am I way off with the filter? is the $(this) required in the filter so that i can do the descendant searching?
Thanks kindly
Building upon those great suggestions below I have found that the following does the trick. I'd missed the fact that the filter closure function must return true/false based on the filter condition. Also, that the ends-with selector is great for asp.net generated ids based on INamingContainer
allRows.show();
allRows.filter(function(){
return $(this).find(
"input[type='hidden'][id$='IsAutoMatchHiddenField']").val() == "False";
}).hide();
$('#mySelector :hidden').filter(
function (index)
{
return $(this).find('.repeatedObject').val() == 'someValue';
}
).hide();
The filter() function needs a boolean to be returned to actually determine whether or not to leave an element in the list. Check the API (http://api.jquery.com/filter/) for more information.
Also, as a sidenote, the val(), html(), text(), and other related functions return the information from the first element in the set. If you want to loop through, you'd have to use each or a for loop.
Couple of suggestions.
The find function needs to return a boolean.
Are you looking for an id? or looking for the value? [id~='IsAutoMatchHiddenField']
The [attribute~=value], will look for a word in the value separated by whitespace, example: [value~='foo'] will not match value="foo-bar" but will match value="foo bar".
.
// Chain your functions, the beauty of jQuery.
allRows.show()
.filter(function(index){
// function needs to return a boolean.
return $(this)
.find("input[type='hidden'][id~='IsAutoMatchHiddenField']")
.val() == 'valuetocheck';
});
I think you need to return a boolean or equivalent from the filter function. How about:
allrows.filter(function() {
return $(this).find(':hidden').length;
}).hide();
Or:
$('tr :hidden').closest('tr').hide();