drupal 7 create a views block that displays based on date range of current node - drupal-7

I've searched for days and not found a clear answer for this.
I'd say I'm intermediate with Drupal (at best). I'm using Views, Panels, CCK, and the Date modules (among others, that may not relate to this question)
I've got a content type of Shows (plays), that has a date range field (from the date module) that is the run date of the show.
I've got 3 views blocks that I filter using the Content: Show Dates - start date and Content: Show Dates - end date fields. These display a list (links) to shows that are of 3 categories, now playing, upcoming, and past shows. They work fine.
Now for the tricky part (for me). I want Panels (Node rewrite for Shows) to decide which one to display in the sidebar while looking at a Content:Show based on whether it is currently running, yet to run, or in the past.
What are the steps to make this happen?
thanks!
jason
Edit: I'm working with Blocks too.

I would suggest to create 3 views (not necessary blocks if you have enabled the "Views content pane" module), one for each date option with a nid as Contextual filter and a display of Content:Node. Then add all the 3 views in one panel page variant one after another. Probably you already have these blocks. So you can clone them and just add a nid Contextual filter.
Another option is to create 3 different variants for the same node type and add a Selection Rule for the Show Date field (Selection Rules screencast). If there are no filters for the date field add some php code. Here is an example.

Related

WiX - Dataset Mismatch

I have a website for my Theatre Institute and on the homepage, I have a Slideshow with Two Repeaters on two different slides connected to two different datasets. I use them to display event information/status from my database collection.
Slide1: recentRepeater <-- recentDataset <-- myCollection (For Recent Events)
Slide2: upcomingRepeater <-- upcomingDataset <-- myCollection (For Upcoming Events)
The Problem
While loading, the dataset2 data is shown in repeater1 i.e. RECENT EVENTS gets displayed in the UPCOMING EVENTS section and it gets corrected after fully loading. Being the first thing to be shown on the site, I do not want it to get messed up. This is a negative impact on my website
How It Works
I have stored dates of the Event in the database as a number in YYYYMMDD format. For example:
20-April-2019 ---> 20190420
I have properly connected the datasets to the repeater elements, set the dataset result limit to 2
I sorted the results to be produced based on the YYYYMMDD number
Ascending for upcomingDataset
Descending for recentDataset
I generate the YYYYMMDD format number for that day and filtered the results produced by the dataset by the .setFilter() function
$w("#recentDataset").setFilter(wixData.filter()
.lt("dateNumber", YYYYMMDD_today)
)
$w("#upcomingDataset").setFilter(wixData.filter()
.ge("dateNumber", YYYYMMDD_today)
)
How can I prevent this from happening..?
Thanks in Advance
It's hard to say what's going on without actually playing with your site. I think both of your datasets are connected to the same collection. I would guess the problem is that the dataset is only being filtered after the page is loaded. You can verify this by turning the console to verbose mode in preview.
If that is indeed the problem, I can think of three possible fixes/workarounds:
Set the filter's in the dataset settings instead of setting them programmatically. (This is the easiest option.)
Hide the repeaters until the filters are set. (This is a bit of a hack.)
Store the promises returned by the setFilter functions and return them using Promise.all() from the onReady(). (This is the fanciest option. I think it will work, but if you don't need to set the filters programmatically, you might as well do option 1 instead.)

Overview page of elements from a Typo3 page tree

I'm primarily a UI and graphic designer and, eventhough I have some experience with Typo3, I'm completely stuck at the following problem:
I have a large page tree with single pages for items from a catalogue (one item per page), the layouts for these items are built with Armin Vieweg's beautiful "Dynamic Content Elements" extension (DCE).
Now I want to create an overview page where I reference some of those items automatically - ideally I want to check a box in each element I want to display there (I would add a field catalogueItemPreview to the item DCE which authors can check or uncheck).
Unfortunately, I have no concrete idea of how the database is structured and how I could build a query (where would I even do that? in a custom-made plugin?).
This is how I imagine it could work: On the overview page I use a plugin/an extension in a Content Element that does the following:
search Typo3 DB for content elements with a field called "catalogueItemPreview"
return fields "catalogueItemTitle", "catalogueItemShortDescription", "cataloguePreviewImage"
use a template to render previews of all those elements on the overview page
I'm happy for ANY pointers towards a solution as currently I'm completely in the dark about where even to begin ...
Schematic screenshot from the Typo3 backend
thanks for using my DCE extension :)
Well the fields you have defined and their values in content elements are stored as XML, because the current version of DCE is based on Flexforms.
This makes it very very difficult to do MySQL queries using one of the field properties in WHERE clause. You could check for a xml string in the field pi_flexform but this is not recommended.
Instead I would use another property of content elements (tt_content) to mark the items as "Show on frontpage". For example you could create a new layout or section_frame value for that. Then it is very easy to just output the elements you want, using TypoScript.

drupal views display needs multiple sort order for exposed filter

I have a 4 quicktabbed views blocks on a page and rightnow. All blocks show lists that can be sorted by "Title" with an exposed filter and a sort order dropdown button for options "A-Z" and "Z-A". So the user can view the list either way. I need to add another exposed filter option for posted date. I see how to do that and it's now an option in the pulldown button that shows "Title" but I can't see how to add option for "most recent" and "oldest" either in the sort order dropdown button or anywhere. Can this be done in the views UI or is this going to involve some php coding? If php, where do I start, given I'm a php newbie?
I don't know if you've figured it out yet, I had to do something similar recently.
this answer helped me [Drupal 7: Exposed filter on a post date just to set up a created date filter.
As for the newest/oldest sort, you add Content: Post date to your Sort criteria, the you could maybe check the Advanced sort options in BEF Settings for your view. There you can combine 'sort order with sort by' like the following current_value|replacement_value pair:
Publication date Asc|Oldest
Publication date Desc|Newest
Let me know if that was helpful in any way or if you need a more detailed answer

Atk4 form Columns

I'm trying to use columns in a form.
I have the next code, that produces the
The code is this:
$col=$this->add('Columns');
$left=$col->add($f->addField('text','observaciones'));
$right=$col->add($f->addField('line','cantidad_de_bocas'));
the fields of the columns, are based on form fields. I whant to add more than one field to the columns (ex. 2 fields on left column and 4 fields on right columns).
I have seen some examples about this, like
$col=$page->add('Columns');
$left=$col->addColumn(2)->add('View_SlotMachine');
$right=$col->addColumn(2)->add('View_SlotMachine');
Why the fields are duplicated ?
What does the method addColumn(2) does ?
Very thanks
If you havent gone to far with development using atk 4.1, you could download 4.2 and look at the examples here. There is a lot of new functionality in 4.2 which you can take advantage of and the demos and examples are being updated to reflect these changes.
In 4.2, there is an example of styling with two columns like this
class StylingForm extends Form {
function init(){
parent::init();
$f=$this;
$f->addField('line','name')->validateNotNull()
->setFieldHint('Click "Register" to see error');
$f->addField('line','email')
->validateNotNull()
->validateField('filter_var($this->get(), FILTER_VALIDATE_EMAIL)')
.. .. ..
}
functoin init() {
// Stacked class puts labels on top of fields
$form=$page->add('StylingForm');
$form->addClass('stacked atk-row');
$form->template->trySet('fieldset','span6');
$sep=$form->addSeparator('span6');
$form->add('Order')->move($sep,'before','age')->now();
}
In atk4.1, the form is a view so it has a template in atk4/templates/shared/view/form.html and some code in atk4/lib/View/form.php
In the example of the slot machine that you mention from here the addColumns(2) is being used to set the width of the views to 20% of the available screen width but in the example, each column will contain a view of the slot machine. If you wanted to forms on the same page, you could use the same functionality, but what you appear to want is a single form across two columns with a single submit button.
If you have to continue to use atk4.1, you need to look at the form.html. Romans may be able to suggest how you could create a two column form in that version. I can see there are some classes defined in the css such as atk-form-vertical-2col and atk-form-vertical-3col and there is a function setFormClass to set them but i cant see what tags you would set to put fields into the right hand side - by default, everything goes to the left.

How to customize node page view?

There is a list of cars for rent (list of nodes of material type "car rental"). Each car has a page of details. On the page there is a table of the cost depending on the duration of the lease (here is page screenshot):
As I see it, I need to add fields for the type of material "car rental":
Day
Week
Weekend
7-21 days
21 days
Deposit
And then, somehow, render this fields to a table.
How to best implement it in Drupal 7?
How to do it best might vary depending on who you talk to. But I would probably use a node--car_rental.tpl.php solution. And code the table my self in html. This restricts the page to be dynamic with more fields, but it is easy to implement. But if you want more dynamic solution without needing to coding files, I would use the Display Suit module
and some CSS.

Resources