m-tilab / liferay-schema-hook

in this module you can add schema structured data for pages and custom assets in liferay. this module is compatible with Liferay CE 7.1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

liferay-schema-hook

At first for deploy this module, copy this into module folder of your liferay workspace.

supported Schema Types:

  • MusicRecording
  • WebPage

for add new schema support, must be implement BaseSchema class.

In the module which is using the base schema module.You need to add to your dependencies, base module object:

compile project(":modules:schema-hook")

And populate your schema object same as this:

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    String imageUrl = "";
    if (_music.getCoverFileEntryId() > 0) {
    	FileEntry ImageEntry = DLAppServiceUtil.getFileEntry(_music.getCoverFileEntryId());
    	imageUrl = DLUtil.getPreviewURL(ImageEntry, ImageEntry.getFileVersion(), themeDisplay, "&imageThumbnail=1");
    	String[] imageSplit = imageUrl.split(StringPool.PERIOD + ImageEntry.getExtension());
    	imageUrl = imageSplit[0] + StringPool.PERIOD + ImageEntry.getExtension();
    }
    Layout layout = themeDisplay.getLayout();
    String completeURL = PortalUtil.getCanonicalURL(PortalUtil.getCurrentCompleteURL(request), themeDisplay, layout);
    String artistName = "";
    MusicRecordingSchema musicRecordingSchema = new MusicRecordingSchema(layout.getName(themeDisplay.getLocale()), layout.getDescription(themeDisplay.getLocale()),_music.getGenre(), artistName, LanguageUtil.get(request, "music-download"),_music.getTitle(themeDisplay.getLocale()), imageUrl, imageUrl, artistName, LanguageUtil.get(request, "music-enthusiasts"), completeURL, completeURL);
    request.setAttribute("LIFERAY_SHARED_SCHEMA", musicRecordingSchema.toJSON());

this code completed by me and Ms. maryam koochaki

About

in this module you can add schema structured data for pages and custom assets in liferay. this module is compatible with Liferay CE 7.1


Languages

Language:Java 99.8%Language:CSS 0.2%