Filter block types based on the site in episerver - episerver

I have a multisite setup in episerver. There are a few properties of a certain block type that i need to update using a scheduler that is applicable for some selected sites only. I need to loop through the filtered sites & get the list of blocks within that site.
Is this possible to achieve ?
foreach (var siteDefinition in siteDefinitionRepository.List().Where(s =>s.Name.Equals("Alloy")))
{
//get all the blocks of carousal blocks
}

Related

Episerver sorting order of pages should not effect website pages sorting order

When i am sorting order of the pages in Episerver, its affecting the website also. means website pages are also changes sorting order.
how we can sort order of pages in episerver in a way that it should not affects website page sorting order.
Is there any configuration or settings in episerver?
Assuming you have a PageDataCollection you use the FilterSort class
Example
// your pages
PageDataCollection _newsPageItems;
FilterForVisitor.Filter(_newsPageItems);
new FilterSort(FilterSortOrder.PublishedDescending).Filter(_newsPageItems);
// The _newsPageItems are now filtered and sorted
This is the standard way of sorting and securing listed information from Episerver, also read the article Searching for pages based on page type
Considering you use the DataFactory to fetch a list with pages you can build a PageDataCollection from a Enumerable<PageData> object instance
Also using the DataFactory is bad practice and you should be using FilterForVisitor as well. My recommended implementation would be
// Construct an IContentLoader, this can also be done using Dependency Injection
var loader = ServiceLocator.Current.GetInstance<IContentLoader>();
// Get the children of your reference
var children = loader.GetChildren<PageData>(pageLink, LanguageSelector.AutoDetect(true));
// Construct new PageDataCollection and filter for visitor
var sortableChildren = EPiServer.Filters.FilterForVisitor.Filter(children);
// Sort
FilterSort sortFilter = new FilterSort(FilterSortOrder.CreatedDescending);
sortFilter.Sort(sortableChildren);

Common Exposed filter for each tab in drupal 7

I have different fields and showing in different blocks, and want to apply exposed filter to all but my problem is it shows different exposed filters for each different block. I want to make it common for each block.
Below are the steps,
I made 5 blocks to be displayed for each buttons.
Added exposed filter for languages for each block.
Now each block showing its different exposed filter.
But I want the exposed filter should be shown above the buttons and should work for each block display. Attached screenshot for the issue.
I installed Views Global Filter but is gives Session error.
I was just about to suggest the Views Global Filter.
Another way is to set a contextual filter on all your blocks that pulls from the url, so they each pull the same value.
This is an active issue in the views issue queue, with a few people who have made it work:
https://www.drupal.org/node/1587894
Comment #6 has some simple code, and that would be applied here
https://www.drupal.org/node/1871388
After 3 days, I haven't found the solution, even by programmatically.
Then what I had the last option(in my mind, huh) is,
I get all the fields in one block only, not creating the different blocks for different tab or buttons.
Used the description of Better Exposed Filters, in which I pasted my buttons/tab UI HTML as its.
Now on changing the language all the fields are fetched according to the selected language. But in this case my active tab/button get lost its activeness.
Now, I need to get the last active tab/buuton, so that I can click it again to get the active tab after filtering my languages.
Below is the piece of code which is need to my js file.
// Active target element to make the tab/button active after
// ajax responds in filter
var activeTargetElement;
Drupal.behaviors.events = {
attach: function (context, settings) {
$('#views-exposed-form-MY_VIEW_MACHINE_NAME-BLOCK_NAME', context).ajaxStart(function () {
// my tabs/button are active on the basis of data-target attribute,
// so need to memorise which tab/button is active before fitering any language
activeTargetElement = $('#MY_TABS li.active a').data('target');
}).ajaxSuccess(function () {
// if any target is memorised, then simply click it or trigger a click event for it
if($('[data-target="'+activeTargetElement+'"]').length){
$('[data-target="'+activeTargetElement+'"]').click();
}
});
}
};

displaying the custom block only in full view mode in drupal7

Iam New to drupal.I have created a custom block in drupal7.Now In this Block I want to display the data of custom content type(i.e for example Advertisements).This Advertisements have a faciltity to display the ads in homepage,teaser,full view mode page.
Now the problem is I want to get programatically the view mode of block similar to node view so that I can get the advertisements related to that view(i.e advertisements with teaser view) etc..
This is how I have implemented but it failed to show the view mode
/**
* Implements hook_block_view().
*/
function Advertisement_block_view($delta = '',$view_mode) {
echo $view_mode;
$block['subject'] = t('Advertisements');
$block['content'] = Advertisement_block_content();
return $block;
}
Please help with this..
Thankyou
By default Blocks do not support view modes. Not the way nodes do at least as far as I know of. Take a look at the Drupal API on the hook_block_view() you used. It doesn't mention a $view_mode argument. You should actually be getting a warning if used.
Getting Advertisements (nodes) of a certain view mode sounds somewhat weird imo since you don't assign view modes onto nodes but onto a content type which means that all Advertisement nodes would be able to be viewed in a certain view mode once it is assigned to its content type.
If you want to get all view modes configured on a content type you can use: field_view_mode_settings($entity_type, $bundle) in which you pass $entity_type = 'node' & $bundle = 'Your_advertisement_content_type_machine_name'

SharePoint 2010: Custom Silverlight Web Part history field

I'm creating a custom application to view, create and manage a SharePoint 2010 list through a Silverlight 3 application. NOTE: It is a client side application
I've managed pretty much all the basic functions, loading the items of the list, creating new items, editing them etc... but I'm stuck with one specific function.
I have a text field ("multiple lines of text" in SharePoint) which has versioning activated, so as to keep a track of who, and when, each comment was made.
My problem is that I can't find a way to access the previous entries, using:
var comments = myListItem.FieldValues["Comments"];
commentsField.Text = comments.ToString();
returns a string of the most recent entry, but not of the previous entries.
I would like to be able to access all the comments made, together with who made them and when they were made.
Could you help me or point me to the right direction?
Thanks,
Kenny
Try this:
foreach (SPList list in yourList)
{
foreach (SPListItem item in list.Items)
{
foreach (SPListItemVersion version in item.Versions)
{
SPField temp = version.Fields["Comments"];
//use your temp
}
}
}

Loading dropdownlists

what is the best way to load dropdown lists from reference/lookup tables for a desktop application?
the application is layed out into 3 tiers. I've built up my entities.
the front end has a form with 6 tabs. and one big save (another discussion :)
Should I load them all when the form is initially loaded? Are there any caching mechanisms I could use?
it is vb.net app on a network drive that is accessed by several users.
it's also worth noting that some reference tables may be updated. Via another form.
thanks
T
Lots of factors. One you need to populate in constructor so the data is there to populate the visual elements. Beware that just because a tab is not visible does not mean it is not loaded when you app starts.
For a static list of strings
public class Library : INotifyPropertyChanged
{
private List<string> dropDown1;
public List<string> DropDown1 { get { return dropDown1; } }
public Library()
{
// use data reader to populate dropDown1
}
}
I know this will get comments that can use something lighter than a List but List has a lot of nice features, easy syntax, and easy to populate. As a next step you could structure as a client server and use some static so the list is populated once and then shared by all. If you have more properties then substitute string with a class. For a dynamic list then in the get you grab the current data from the table on demand. In your get you could hold on to the last list and if the next request is within X seconds then return stale data. It depends on if stale data is acceptable.
There are many other approaches and I do not pretend this is the best. Just putting out a relatively simple example to get you started.
When it gets to hierarchical then things get a little more complex. There you can use ADO.NET table to store the static dependent data and then apply a filter on a view.
If its a web page you don't have to load all tabs on page load.
Desktop i think it will be more easy and it should be like that.
Only when the user click on the tab show the page and hide all the pages
associated for other tabs.
i hope all tab pages values will be on session so that user can go and come back to any tab and your Big Save at last.
Something useful related to your question i found here
http://www.syncfusion.com/FAQ/windowsforms/faq_c93c.aspx
and one more

Resources