TypoScript: mixed menu of public and access restricted pages - menu

I want to make a menu containing both public and access restricted pages, based on the following requirements:
public pages should be linked, regardless whether the user is logged in or not
access restricted pages should not be linked if the user is not logged in
access restricted pages should be linked if the user is logged in
This is what I have so far:
lib.menu = HMENU
lib.menu.1 = TMENU
lib.menu.1 {
// Satisfies requirement 2
NO.doNotLinkIt = 1
// Satisfies requirement 3
USR = 1
}
However, as you would expect, requirement 1 isn't satisfied this way. I can't come up with a way to make lib.menu.1.NO conditional based on the page being public or access restricted.

If you set NO.doNotLinkIt = 1 then all normal pages are not linked. Actually you want to set showAccessRestrictedPages = <uid> where the uid is the ID if your page with the login form. See documentation. You can set CUR.doNotLinkIt = 1, for requirement 2.

Try this it will also make access restricted page visible irrespective of login status
menu.right.3 = TMENU
menu.right.3.wrap = <ul>|</li></ul></li>
menu.right.3 {
expAll = 0
NO.ATagTitle.field = title
NO.allWrap = <li>|</li>
ACT = 1
ACT.ATagTitle.field = title
ACT.allWrap = <li class="active">|
showAccessRestrictedPages = <login page uid>
showAccessRestrictedPages.addParams =
&return_url=###RETURN_URL###&pageId=###PAGE_ID###
}

Related

Cognos use javascript to clear 2 out of 4 prompts

I have a report which contains 4 prompts. These prompts are located on the actual report page. This is a report created against the metrics studio package.
prompt 1 is strategie and always needs to be selected.
prompt 2: is a scorecard prompt
Prompt 1 and 2 are required.
Prompt 3 and 4 are placed in a conditional block and dependant on what is selected in prompt 2: prompt 3 or 4 will be shown.
Prompt 3 and 4 are optional. These are a supposed to show a subset of scorecards. (Basically I am trying to figure out a way to use cascading prompt functionality for scorecards.)
This all works fine. Until the user wants to change his selection for prompt 2. Cognos does NOT clear previously made selections for prompt 3 (for example). So the report will not show the new selection for prompt 2 but will still show the old selection for prompt 3.
In order to get around this, I wanted to use some javascript to clear the prompts. I admit, I avoid javascript like the plague in Cognos, so I am not very experienced at it. I did try to find a solution and it came up with some suggestions but these cleared all the prompts I just want to be able to clear prompts 3 and 4 not all of them.
i have found this snippet which works pretty well but unfortunately it clears all the prompt values:
<script type="text/javascript">
var oCR = cognos.Report.getReport("_THIS_");
function clearAllValues() {
var aControls = oCR.prompt.getControls();
for (var i = 0; i < aControls.length; i++) {
aControls[i].clearValues();
}
}
oCR.onload = clearAllValues();
</script>
A second example I found, which seemed closer to what I wanted to do was:
function clearRefresh() {
var oCR = cognos.Report.getReport("_THIS_");
var vNationality = oCR.prompt.getControlByName("Nationality");
var vDomicile = oCR.prompt.getControlByName("Domicile");
var vLevel = oCR.prompt.getControlByName("Level");
var vFeeCategory = oCR.prompt.getControlByName("Fee");
var vCourseStage = oCR.prompt.getControlByName("CourseStage");
vNationality.clearValues();
vDomicile.clearValues();
vLevel.clearValues();
vFeeCategory.clearValues();
vCourseStage.clearValues();
oCR.sendRequest (cognos.Report.Action.REPROMPT);
} </script>
<a href="JavaScript:clearRefresh()">Clear All & Refresh
I have tried to combine these two as follows:
<script type="text/javascript">
var oCR = cognos.Report.getReport("_THIS_");
function clearValues() {
var vVPE = oCR.prompt.getControlByName("VPE");
var vSPEC = oCR.prompt.getControlByName("SPEC");
vVPE.clearValues();
vSPEC.clearValues();
}
oCR.onload = clearValues();
</script>
I have found many examples on how to clear ALL the selected prompts within a report but have not found any that allow for a single deselect of a prompt.
I have tried to modify my prompts 3 and 4 to be multiselect prompts so the users could just click the default deselect button but - yeah.... the users did not want that.
If there is a smarter way to design my report, please do let me know.
If you just want clear prompt 3 and 4 .
Click on prompt 3 - properties- Miscellaneous - Name.
Type 'Name3' and similarly 'Name4' for prompt 4.
Now change your JS to below
<script type="text/javascript">
function clearRefresh() {
var oCR = cognos.Report.getReport("_THIS_");
var f = getFormWarpRequest();
var Name3 = f._oLstChoicesName3;
var Name4 = f._oLstChoicesName4;
Name3.selectedIndex = -1;
Name4.selectedIndex = -1;
oCR.sendRequest (cognos.Report.Action.REPROMPT);
}
</script>

How to give data dynamically in a dialog box using visual c++

How can I send data to a dialog box dynamically?
In a previous project I used edit boxes (e.g for 3 conductors) and gave those data separately for each conductor. Now I have to give them dynamically and I don't have standard number of conductors and I can't use edit box again.
Could you please give me an idea or a good link describing step by step how to create a table in a dialog box dynamically?
I have created a dialog box in which I insert data about conductors (resistivity, permeability, diameter etc (electric power systems Smile | :) )) in edit boxes but I have done it only for 3 conductors. I have to insert-edit the number of conductors and then edit their characteristics. But I can't use again edit boxes because this is static. I want something like a dynamic table which will have rows=number of conductors and columns about is characteristic (resistivity, permeability, diameter)and edit them in dialog box. I don't know how to upload my executable to male clear what I have done but here is a part of my code for the static case of three conductors Smile | :) I want another dynamic way to edit data :/
void CInputView::OnLinefeaturesFeatures()
{
// TODO: Add your command handler code here
CInputDoc* pDoc = GetDocument();
CFeaturesDialog DialogWindow;
DialogWindow.m_DialogCon = m_NumCond;
DialogWindow.m_DialogLayers = m_Layers;
DialogWindow.m_DialogPermeability = m_AirPermeability;
DialogWindow.m_DialogAirConductivity = m_AirConductivity;
DialogWindow.m_DialogAirPermittivity = m_AirPermittivity;
DialogWindow.m_DialogEarthPermeability1 = m_EarthPermeability1;
DialogWindow.m_DialogEarthConductivity1 = m_EarthConductivity1;
DialogWindow.m_DialogEarthPermittivity1 = m_EarthPermittivity;
DialogWindow.m_DialogDepth = m_depth;
DialogWindow.m_DialogEarthPermeability2 = m_EarthPermeability2;
DialogWindow.m_DialogEarthConductivity2 = m_EarthConductivity2;
DialogWindow.m_DialogEarthPermittivity2 = m_EarthPermittivity2;
DialogWindow.m_Dialogfrequency = m_frequency;
if (DialogWindow.DoModal() == IDOK)
{
m_NumCond = DialogWindow.m_DialogCon;
m_Layers = DialogWindow.m_DialogLayers;
m_AirPermeability = DialogWindow.m_DialogPermeability;
m_AirConductivity = DialogWindow.m_DialogAirConductivity;
m_AirPermittivity = DialogWindow.m_DialogAirPermittivity;
m_EarthPermeability1 = DialogWindow.m_DialogEarthPermeability1;
m_EarthConductivity1 = DialogWindow.m_DialogEarthConductivity1;
m_EarthPermittivity = DialogWindow.m_DialogEarthPermittivity1;
m_depth = DialogWindow.m_DialogDepth;
m_EarthPermeability2 = DialogWindow.m_DialogEarthPermeability2;
m_EarthConductivity2 = DialogWindow.m_DialogEarthConductivity2;
m_EarthPermittivity2 = DialogWindow.m_DialogEarthPermittivity2;
m_frequency = DialogWindow.m_Dialogfrequency;
}
}

How do I disable products in Kentico 10?

I am performing CRUD operations for products of e-commerce site in kentico 10.I can add and update products using below API
SKUInfoProvider.SetSKUInfo(updateProduct);
Also there is an API for deleting product
SKUInfoProvider.DeleteSKUInfo(updateProduct);
But I do not wish to delete the product from database,rather just disable them so that they do not show up to the end users and still stay in the database .
This are the SKU Objects for the product :
var sku = new SKUInfo
{
//SKUName = Convert.ToString(dr["SHORT_DESCRIPTION"]).Trim('"') + " (" + Convert.ToString(dr["MANUFACTURER_PART_NUMBER"]) + ")",
SKUName = Convert.ToString(dr["MANUFACTURER_PART_NUMBER"]),
SKUDescription = Convert.ToString(dr["TECHNICAL_SPECIFICATIONS"]).Trim('"'),
SKUShortDescription = Convert.ToString(dr["SHORT_DESCRIPTION"]).Trim('"'),
SKUPrice = ValidationHelper.GetDouble(dr["RESELLER_BUY_INC"], 0),
SKURetailPrice = ValidationHelper.GetDouble(dr["RRP_INC"], 0),
SKUEnabled = true,
SKUSiteID = siteId,
SKUProductType = SKUProductTypeEnum.Product,
SKUManufacturerID = manufacturer.ManufacturerID,
SKUDepartmentID = department.DepartmentID,
SKUHeight = 100,
SKUWidth = 100,
SKUAvailableItems = 1,
SKUSellOnlyAvailable = true
};
I tried to set SKUEnabled as false but still user can see the product.So, is there any property to disable products ?
How are you displaying the Sku? If it's a repeater, you may need to filter by the "SKUEnabled = 1" in your where condition.
Another option is if the Product has a Page (it's not a stand alone sku) you can unpublish the page itself.
Well... A user doesn't see products per say - he sees pages that are connected to your SKUs/products. When you disable the SKU - the page is still visible, but (if I am not mistaken) "Add To Cart" is not shown. You need to unpublish product pages. You need to set DocumentPublishTo of the document to some date before for ex:
ProductNode.SetValue("DocumentPublishTo", DateTime.Now.AddDays(-1));

Two Web Parts connection doesn't work when set programmatically

I've a SharePoint 2010 page with a list. The list has several items and a field named "Department" and must filter items based on user's department value retrieved from user profile.
To do this I've created a feature which upon activation adds UserContextFilterWebPart to the page and makes connection between UserContextFilterWebPart and XsltListViewWebPart. After the feature is activated I can see in the page design mode that connection is established but the list gets empty. Then I open web part's menu, choose "Connections" then "Send Filter Values To" and click "List1". When dialog appears I do nothing but only click "Finish" button and it begins to work fine. Can anybody please explain me why the connection begins to work only if I do that manual extra action? What must be done to fix?
I tried different way when List.Views[0].Query property is set to appropriate CAML query and it also works fine. But I'm told that it's not a good approach because of performance and parallel tasks issues. Is it really bad course of action?
Below is the code for 2 different approaches.
Thanks in advance!
1-s variant with UserContextFilterWebPart:
SPSite Site = new SPSite(URL);
SPWeb Web = Site.OpenWeb();
SPLimitedWebPartManager WPM = Web.GetLimitedWebPartManager(URL, PersonalizationScope.Shared);
XsltListViewWebPart List = WPM.WebParts[0] as XsltListViewWebPart;
UserContextFilterWebPart UCFWP = new UserContextFilterWebPart();
UCFWP.Title = "Current User Filter";
UCFWP.AllowEdit = true;
UCFWP.FilterName = "Current User";
UCFWP.SendEmptyWhenNoValues = true;
UCFWP.AllowClose = true;
UCFWP.ExportMode = WebPartExportMode.All;
UCFWP.AllowConnect = true;
UCFWP.AllowHide = true;
UCFWP.ProfilePropertyName = "Department";
UCFWP.ValueKind = UserContextFilterValueKind.ProfileValue;
UCFWP.ZoneID = "Main";
WPM.AddWebPart(UCFWP, UCFWP.ZoneID, 1);
WPM.SaveChanges(UCFWP);
ConsumerConnectionPointCollection consumerConnections = WPM.GetConsumerConnectionPoints(List);
ConsumerConnectionPoint addConsumerConnPoint = consumerConnections["DFWP Filter Consumer ID"];
ProviderConnectionPointCollection providerConnections = WPM.GetProviderConnectionPoints(UCFWP);
ProviderConnectionPoint addProviderConnPoint = providerConnections["ITransformableFilterValues"];
TransformableFilterValuesToParametersTransformer trans = new TransformableFilterValuesToParametersTransformer();
trans.ConsumerFieldNames = new string[] { "Department" };
trans.ProviderFieldNames = new string[] { "Department" };
SPWebPartConnection newConnection = WPM.SPConnectWebParts(UCFWP, addProviderConnPoint, List, addConsumerConnPoint, trans);
WPM.SPWebPartConnections.Add(newConnection);
2-nd variant with CAML query (intended to be used not in a feature but in a web part):
SPSite Site = new SPSite(URL);
SPWeb Web = Site.OpenWeb();
SPLimitedWebPartManager WPM = Web.GetLimitedWebPartManager(URL, PersonalizationScope.Shared);
XsltListViewWebPart List = WPM.WebParts[0] as XsltListViewWebPart;
SPUser CurrentUser = Web.CurrentUser;
SPServiceContext context = SPServiceContext.GetContext(Site);
UserProfileManager upm = new UserProfileManager(context, false);
UserProfile up = upm.GetUserProfile(CurrentUser.RawSid);
String UserDepartment = up["Department"].Value.ToString();
SPView ListView = Web.Lists["List1"].Views[0];
ListView.Query = "<Where><Eq><FieldRef Name='Department' /><Value Type='Text'>" + UserDepartment + "</Value></Eq></Where>";
ListView.Update();
I had a similar problem of connecting two web parts. I found the answer here: http://kvdlinden.blogspot.dk/2011/02/programmatically-connect-two.html
Note that that post describes how to do it with two XsltListViewWebParts. In order to use it in your case I suggest that you:
Create the connection manually,
Use PowerShell to get a SPLimitedWebPartManager for the page,
Use the manager to iterate through the manager.SPWebPartConnections,
And find the ProviderConnectionPointID for your connection,
Use that ID in the code shown in the post.
Also remember to setup the transformer - you can find this also from the SPWebPartConnections.
Next time you activate your feature you should have a connection equal to the one you made by hand.

How to use content slide with RECORD objects in typoscript

On one of my sites, content (Videos) is inherited from the levels above if the content column is empty (in this case: colPos=3 / Border)
To create the output, I use
temp.myObject < styles.content.getBorder
temp.myObject {
slide = -1
}
Easy, because this is taken from a CONTENT object and slide is a built-in function.
Due to our system setup I need to do something similar with the RECORDS object. But the following typoscript doesn't work - it generates empty output:
temp.myObject = RECORDS
temp.myObject {
tables = tt_content
source.cObject = CONTENT
source.cObject {
slide = -1
table = tt_content
renderObj = TEXT
renderObj.field = uid
}
}
The same happens with this snippet:
temp.myObject = RECORDS
temp.myObject {
tables = tt_content
source.cObject = CONTENT
source.cObject {
table = tt_content
select {
pidInList.data = leveluid:-1,slide
}
renderObj = TEXT
renderObj.field = uid
}
}
[Note: The complicated source part above provides the ID of a content element from where we extract an image file from the flexform xml]
Can somebody help me to achieve a contentslide solution based on the RECORDS object?
If there are any problems understanding the questions, please ask.
CONTENT object doesn't have "slide" property.
Try simulate slide using stdWrap.ifEmpty.cObject.... for Your RECORDS object, as it could be done for slide simulation for TYPO3 3.8.x.
Example on TYPO3 wiki :
http://wiki.typo3.org/wiki/Content_Slide#Content_Sliding_in_TYPO3_3.8.x_by_TS_only

Resources