Orchard: Difference between Display.User() and New.User() - orchardcms

What is the difference between Display.User() and New.User() in Orchard templates?
I see this line of razor code in Core\Shapes\Views\Layout.cshtml:
Model.Header.Add(Display.User(), "10");
Where as there is this line of code in Themes\TheThemeMachine\Views\Layout.cshtml:
WorkContext.Layout.Footer.Add(New.User(), "10");

The first one is a mistake and should be replaced by Model.Header.Add(New.User(), "10");.
New.ShapeName() instantiates a new shape but does not render it.
#Display.ShapeName() instantiates and renders a new shape.

Related

Identify Reference to Destroy & Re-Initialize Swiper in Elementor

Elementor Pro (the WordPress page builder) integrates beautifully with Swiper, tying their GUI to the JS parameters and database content.
However, for my project, I need to make some changes to the Swiper "CoverFlow" skin Init parameters (show more slides, change the 3D effect facing direction...).
My hope is to to use the Destroy method of the Swiper API which looks like:
mySwiper.destroy(deleteInstance, cleanStyles);
Then I can initialize the Swiper again, with my own custom parameters. The challenge is that the way Elementor calls Swiper in frontend.js is a complex anonymous function that doesn't really allow me to know what "mySwiper" would be... On line 567:
this.swipers.main = new Swiper(this.elements.$mainSwiper, this.getSwiperOptions());
I would be so grateful if someone could please help me understand what "this.swipers.main" would translate to after Init so that I can destroy the swiper and initialize it again with my own parameters.
Obviously I cannot edit frontend.js itself as it is a plugin file that needs to be updated.
Extra points for whomever teaches me how to fish and what the methodology is to solve these types of puzzles for other similar situations.
You can give an ID to the Elementor widget ex: slider1 and then with JS you can use:
var sliderInstance = document.querySelector('#slider1 .swiper-container').swiper;
After this you can call sliderInstance.destroy() wherever you want.
And if you want to initialize it again you can call:
var sliderInstance = new Swiper('#slider1 .swiper-container', {
//options
});

vaadin 7: layout displaced after opening/closing dialog window

I am new to the forum and to programming so hopefully I give you enough details and precise information needed to understand my question.
I am working with vaadin 7 in java EE web aplication and I have a layout problem/phanomena that I cannot explain and I could not find a solution on the net. Basically, when I start the server and test my application on localhost everything looks right. When I open a dialogue window and close it again, the layout of the site looks displaced. I could not find a pattern as to which click causes this effect. Sometimes it happens also when I only change a view. This is how it should look like and this is how it does look like after working in the application.
I looked through the devloper tool in the browser and noticed that in the working html, the attributes "top" and "left" are set for the gridlayout-slot. In the displaced layout these attributes are not set. Furthermore, it seems that the problem occurs more often in chrome. It does also happen in firefox but less often.
I use VerticalLayout, GridLayout and FormLayout.
Did you have similar experience? I am wondering how and when the html files are generated from the vaadin code to find out why they change and how I can fix it.
I am not sure which code exactly is causing the problem, so I am not sure what to post. If you have an idea where to look, I can add more code. Here is how the Dialog is set up:
public class Dialog extends Window implements ClickListener
public Dialog(CustomController controller, String title)
{
super(title);
setModal(true);
setStyleName("dialogWindow");
this.controller = controller;
setWidth("65.0%");
setHeight("90.0%");
// top level component properties
panLayout = new GridLayout();
panLayout.setWidth("100%");
panLayout.setHeight("100%");
buildPanToolbar();
panLayout.addComponent(panToolbar);
buildPanTop();
panLayout.addComponent(panTop);
buildPanTabs();
panLayout.addComponent(tabsheet);
panLayout.setComponentAlignment(tabsheet, Alignment.MIDDLE_CENTER);
panLayout.setRowExpandRatio(2, 1.0f);
tfThema.focus();
setContent(panLayout);
}
The buildSomething() functions are all a combination of GridLayout, FormLayout, HorizontalLayout and VerticalLayout. Below is the buildPanToolbar() function as an example
private void buildPanToolbar()
{
panToolbar = new HorizontalLayout();
panToolbar.setImmediate(false);
panToolbar.setWidth("100%");
panToolbar.setHeight("25px");
panToolbar.setMargin(false);
panToolbar.setSpacing(true);
panToolbar.setStyleName("toolbar");
HorizontalLayout panHelpToolbar = new HorizontalLayout();
panHelpToolbar.setImmediate(false);
panHelpToolbar.setWidth("-1px");
panHelpToolbar.setHeight("25px");
panHelpToolbar.setMargin(false);
panHelpToolbar.setSpacing(true);
panHelpToolbar.setStyleName("toolbarButtons");
panToolbar.addComponent(panHelpToolbar);
pbButton1 = new Button();
pbButton1.setCaption("Button1Text");
pbButton1.setStyleName(BaseTheme.BUTTON_LINK);
pbButton1.setImmediate(true);
pbButton1.setWidth("100px");
pbButton1.setHeight("-1px");
pbButton1.setIcon(new ThemeResource("../images/pic1.gif"));
pbButton1.addClickListener(controller);
panHelpToolbar.addComponent(pbButton1);
panHelpToolbar.setComponentAlignment(pbButton1, Alignment.MIDDLE_LEFT);
pbButton2= new Button();
pbButton2.setCaption("Button2 Text");
pbButton2.setImmediate(true);
pbButton2.setWidth("100%");
pbButton2.setHeight("-1px");
pbButton2.setStyleName(BaseTheme.BUTTON_LINK);
pbButton2.setIcon(new ThemeResource("../images/pic.gif"));
pbButton2.addClickListener(this);
panHelpToolbar.addComponent(pbButton2);
panHelpToolbar.setComponentAlignment(pbButton2, Alignment.MIDDLE_LEFT);
}

How do I set the value of a ContentPartRecord on a widget from the command line in Orchard?

I have created a custom module in Orchard CMS. This module contains several widgets. One of these widgets (let's call it WinnersFeedWidget) contains a couple of custom Contant Part Records (let's call them NumberOfWinnersToShow and SkinName).
I can add the WinnersFeedWidget to a zone by using the command
widget create WinnersFeedWidget /Title:"Recent Winners" /Zone:"AsideSecond" /Position:"2" /Layer:"Default" /Identity:"WinnersContainerWidget" /RenderTitle:true
but I would like to be able to set the values of NumberOfWinnersToShow and SkinName from the command line as well.
How can I achieve this?
For the benefit of anyone looking for an answer to this question-
Because I was creating a recipe, I was able to achieve the same effect by adding the following XML into the element of the recipe:
<WinnersFeedWidget Id="/Identifier=WinnersFeed" Status="Published">
<WinnersFeedPart NumberOfWinnersToShow="15" SkinName="Blue"/>
<CommonPart Owner="/User.UserName=OrchardAdmin" Container="/Layer.LayerName=Default" CreatedUtc="2012-11-20T17:08:00Z" PublishedUtc="2012-11-20T17:08:00Z" ModifiedUtc="2012-11-20T17:08:00Z" />
<WidgetPart Title="Recent Winners" Position="2" Zone="AsideSecond" RenderTitle="true" />
</WinnersFeedWidget>
In this instance, WinnersFeedPart is the name of the part on the widget.
I also had to update my driver class with overrides for Importing and Exporting (to allow the export feature to be able to correctly generate the required XML):
protected override void Exporting(WinnersFeedPart part, ExportContentContext context)
{
context.Element(part.PartDefinition.Name).SetAttributeValue("NumberOfWinnersToShow", part.NumberOfWinnersToShow);
context.Element(part.PartDefinition.Name).SetAttributeValue("SkinName", part.SkinName);
}
protected override void Importing(WinnersFeedPart part, ImportContentContext context)
{
part.NumberOfWinnersToShow= GetIntegerValue(part, context, "NumberOfWinnersToShow");
part.SkinName= context.Attribute(part.PartDefinition.Name, "SkinName");
}
(GetIntegerValue is a helper method that convert the value provided by the importer to an int)
For a good example of this working, I would recommend downloading the Featured Item Slider module from the Gallery, and looking at their Driver class.

Declaring function in Blocks in Drupal 6

I am facing an issue in declaring a fucation in block which I have added . I am calling a function by including an file which ia placed in the theme. I have also tried it by placing out of the theme folder. The function is alredy being user in front page. But when I am using the same function in that block. The screen gets blank and nothing displays. some part of my block coding is written below. Please help me.
<?php
global $base_url;
include($_SERVER['DOCUMENT_ROOT']."/travellar/geoiploc.php"); // indluded file
$ip = "203.189.25.0"; // Australia IP test
$country_code = getCountryFromIP($ip, "code");
I've had no problems loading functions from modules into custom blocks, but I've never tried loading one from a theme before. It's not clear to me whether or not theme functions are loaded before the page content is loaded.
You might have to create a custom module or include file to hold the function. Check out the module_load_include() function for how to load a specific include file.
A custom module would be a good approach as it is loaded before the theme layer and can be accessed from almost anywhere in Drupal except other modules with a lower weight than the custom module. It is also likely to come in handy for hooks and other overrides.
However, if you must have it in the theme layer, another option is adding it to template.php of your theme which should make it available within page.tpl.php and such, but not blocks I don't believe.
/sites/all/modules/mymodule/mymodule.info
name = My Module
package = !
description = It is MY module, not yours!
core = 6.x
The package "!" will make this module appear at the top of the modules page
/sites/all/modules/mymodule/mymodule.module
<?php
// Load mymodule.morePHP.inc
module_load_include('inc', 'mymodule', 'mymodule.morePHP');
// A custom function
function mymodule_my_custom_function($args) {
/* do custom stuff here */
return 'output';
}
/sites/all/modules/mymodule/mymodule.morePHP.inc
<?php
// An included custom function
function mymodule_other_custom_stuff() {
}

com.android.internal.R.id.content cannot be resolved to a variable in alarm clock code

I am using the alarm clock code that I found and trying to customize it.
But I get this error : "com.android.internal.R cannot be resolved to a variable "
for code:
getListView().setItemsCanFocus(true);
// Grab the content view so we can modify it.
FrameLayout content = (FrameLayout) getWindow().getDecorView()
.findViewById(com.android.internal.R.id.content);
I am not sure what this piece of code is doing ( so that I could change it)
Can you please help me resolve this by some alternative piece of code?
The solution is simple.
Just replace: com.android.internal.R.id.content with android.R.id.content
You can directly use R.id.content, you need to have a view by that name in layout.
In your gen->R.java file there should be an int named content which corresponds to a view which should be declared in your res->layout folder. This int would be created automatically by Android.

Resources