How add new option at sulu administration interface? - menu

What steps should I follow to add a new option to the left menu of the SULU administration panel? Following the documentation I did not succeed.

To extend the admin menu you need to create a new "Admin" class in your src/Admin folder and extend from the Sulu Admin class and then:
<?php
namespace App\Admin;
use Sulu\Bundle\AdminBundle\Admin\Admin;
use Sulu\Bundle\AdminBundle\Admin\Navigation\NavigationItemCollection;
use Sulu\Bundle\AdminBundle\Admin\View\ViewCollection;
class EventAdmin extends Admin
{
const EVENT_LIST_VIEW = 'app.events_list';
public function configureNavigationItems(NavigationItemCollection $navigationItemCollection): void
{
$eventNavigationItem = new NavigationItem('app.events');
$eventNavigationItem->setView(static::EVENT_LIST_VIEW);
$eventNavigationItem->setIcon('su-calendar');
$eventNavigationItem->setPosition(30);
$navigationItemCollection->add($eventNavigationItem);
}
}
See more in the documentation here https://docs.sulu.io/en/2.2/book/extend-admin.html and I really can recommend to do https://github.com/sulu/sulu-workshop first to get into sulu.
If you get any error you should show the error instead of saying you tried and it did not work. Look for error in your browser dev tools console, network tab, symfony log or webservers log.

Related

Why my custom C# extention does not execute when deployed to Spotfire WebPlauer/Consumer

I have a simple custom Add-in that just displays a message to the user.
namespace GeorgiSpotfireCustomExtention
{
public class GeorgiEvent : CustomApplicationEventHandler
{
protected override void OnApplicationInstanceCreated(AnalysisApplication application)
{
base.OnApplicationInstanceCreated(application);
MessageBox.Show("On Application Instance Created");
}
}
}
That is my CustomAddIn class:
public sealed class CustomAddIn : AddIn
{
// Override methods in this class to register your extensions.
protected override void RegisterApplicationEventHandlers(ApplicationEventHandlerRegistrar registrar)
{
base.RegisterApplicationEventHandlers(registrar);
registrar.Register(new GeorgiEvent());
}
}
I am just trying to learn the package deployment process. When I am running it locally - in the installed Spotfire Analyst client it displays the message just fine:
However, when I package the extention, add it to the server (via the "Deployments & Packages" section, adding the "spk" file and then saving the area, the message is not shown when I try to open a document in the WebPlayer/Consumer.
Notes: I am choosing "TIBCO Spotfire Any Client" for my intended client in the Package Builder when building the spk file.
from the Spotfire Wiki (emphasis mine):
WinForms graphical user interface is a component of the .NET Framework and not something supplied by Tibco Spotfire. It's not recommended to implement solutions using Forms, but sometimes it could be handy when debugging. There is no commitment that it will work in future versions of the Analyst client. Forms are not supported on the Web Player.
the example listed on the wiki is for IronPython, but presumably the same holds true for C# extensions.
Correct. My assumption, and I don’t really know a lot about .NET, so this is not absolute, is that the form is rendered on the machine executing the code. In the case of your example above, the dialog would pop on the Node Manager host. If you’re really set on using an alert like this, you can accomplish it in JavaScript with an ‘alert()’. There is probably a way to render dialogues o in the web client too, but I don’t know it offhand.

cannot find symbol class LoginActivityError

I am making an app and I have a button that says Sign in and when you click on the button it is supposed to redirect you to a new page that will have you sign in. When i clicked New>Activity and selected a log in page and clicked finish there was an error that says Cannot Find Symbol Class Login Activity. Heres the location of the error in code:
private void addEmailsToAutoComplete(List<String> emailAddressCollection) {
//Create adapter to tell the AutoCompleteTextView what to show in its dropdown list.
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(LoginActivity.this,
android.R.layout.simple_dropdown_item_1line,
emailAddressCollection);
mEmailView.setAdapter(adapter);
}
Open your SDK Manager (Tools menu > Android), and install Android Support Repository in Extras. After this you may need to click the Sync Project with Gradle Files button in the toolbar.
I'm just starting, and I had the same issue.
I added the login activity using Android Studio's wizard, but I didn't use the default activity name.
When the class was generated, it referenced to "LoginActivity.this", using the default name.
In my case, I just needed to replace the Activity name for the one I've used while creating it.
Example:
new ArrayAdapter( "ActualNameOfLoginActivity" .this...

adding custom methods in Hook environment?

i am adding a new method into CalEventLocalServiceImpl using hook...
my code is ..
public class MyCalendarLocalServiceImpl extends CalEventLocalServiceWrapper {
public MyCalendarLocalServiceImpl(CalEventLocalService calEventLocalService) {
super(calEventLocalService);
// TODO Auto-generated constructor stub
}
public List getUserData(long userId) throws SystemException{
DynamicQuery query=DynamicQueryFactoryUtil.forClass(CalEvent.class)
.add(PropertyFactoryUtil.forName("userId").eq(userId));
List deatils=CalEventLocalServiceUtil.dynamicQuery(query);
return deatils;
}
}
liferay-hook.xml:
<service>
<service-type>
com.liferay.portlet.calendar.service.CalEventLocalService
</service-type>
<service-impl>
com.liferay.portlet.calendar.service.impl.MyCalendarLocalServiceImpl
</service-impl>
</service>
my question is how to use getUserData from jsp file.
Can anybody help me out....
i think u didn't gt my question...i want list of events based on USERID from Calendar ...to achieve this task what i need to do??
I assume getUserData() is not overridden but a new method (can't look up currently). This is not what you can do when overriding a service. Instead you'd have to add a new Service and make it available to the portal.
Remember that a customized ("hooked") jsp is running in the portal classloader, while your overloaded service is running in the hook's classloader. Thus, if you create a new service and make the service.jar available to Liferay (e.g. on the global classpath) you can call it from JSPs. The interface of Liferay services can not be extended through an overloaded service.
In case getUserData() is already in the interface (as I said I can't look up currently), you just need to call the CalendarLocalServiceUtil from your jsp and it will be delegated to your wrapper.
Just to add to Olaf's answer and comments...
if you you want to extend CalEventLocalService service with just "getUsetData" and use it in one jsp than building your own service might be overkill. Simply put your code from "getUserData" in jsp. Otherwise follow Olaf's suggestions.

Problems using an installclass in a web setup for a web site

I am trying to create a web setup for my web site, and I want to use an installer class to do some custom stuff. I am using VS 2010, and the web site and installer is .NET 3.5.
I have added reference to the installer class project output in the Install section under Custom Actions:
I have also set /targetdir="[TARGETDIR]/" on the CustomActionData for this action.
The InstallScript project is a standard class library (dll).
There is a public class that inherits from Installer class. It overrides the Install method as I have seen been done in several online examples:
using System.Collections;
using System.Windows.Forms;
namespace InstallScript
{
public class MyWebInstaller : System.Configuration.Install.Installer
{
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
var targetDir = Context.Parameters["targetdir"];
if(targetDir==null) targetDir = "No TARGETDIR!";
MessageBox.Show("TARGETDIR:\t" + targetDir);
}
}
}
I would think there should be shown a message box here som time during the install, but it seems like it is never called. No error is shown either. The setup just runs through as if this code was never called.
Anyone have idea of what is wrong?
OK, I found out what was missing.
You need to specify the class with the class attribute RunInstaller(true) for the setup to pick up and actually run the code.
So the class needs to be declared like this:
[System.ComponentModel.RunInstaller(true)]
public class MyWebInstaller : System.Configuration.Install.Installer
{
...

Sharepoint get User information

I have MOSS server and users authorization is going trough AD.
I want to programmaticaly get some current user information, like e-mail, phome number.
I made the following steps:
1) create dll with [assembly: AllowPartiallyTrustedCallers]
2) i have the class PhoneBookCL that inherits System.Web.UI.WebControls.WebParts.WebPart
and I try to override CreateChildControls() for testing;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.Office.Server;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Portal;
public class PhoneBookCL : WebPart
{
SPUser currentUser = null;
protected override void CreateChildControls()
{
try
{
SPWeb web = SPControl.GetContextWeb(Context);
currentUser = web.CurrentUser;
}
catch (Exception exp) { value = exp.Message; }
}
}
3) assigned strong name to dll, then add SafeControl to web.config:
4) dll -> to \Bin directory, added this WebPart to SP webparts collection,
added the webpart to the new Page.
Refreshing the page going to the exception: unexpected exception.
If I delete
"SPWeb web = SPControl.GetContextWeb(Context);
currentUser = web.CurrentUser;"
then all works great.
I can create Label and change its Text property and other things.
Also I tried to inherit from Microsoft.SharePoint.WebControls.WebPart, which actually inherit UI...WebPart, so the result is the same.
Maybe there is some security issue?
This problem occurs as you are deploying dll to bin. I assume your web.config has trust level as WSS_minimal . Minimal trust will not permit accessing object model.
Therefore , you have the following options:
Deploy the webpart using a wsp with custom code access security. This is slightly tedious.
Change the trust level in web.config to Full.
Deploy the dll to GAC.
From a best practices perspective, deploying the dll to bin with custom code access security will be the best option. But if you dont have security restrictions, you can look at deploying to GAC to keep things simpler.
Reference : http://msdn.microsoft.com/en-us/library/ee909485%28office.12%29.aspx
Regards,
Faiz

Resources