Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
themeEclipse
<div class="block-xxxxxx">
   <div class="sitemap-yyyyyy">
      <div class="top"><!--  --></div>
      <div class="h2-wrapper">
         <h2>
            <span>Sitemap</span>
         </h2>
      </div>
      <div class="wrapper">
         <ul>
            <li>
               <a title="Page ?" class="navigation" href="#">Page ?</a>
               <ul>
                  <li>
                     <a title="Page ?" class="navigation" href="#">Page ?</a>
                  </li>
               </ul>
               <ul>
                  <li>
                     <a title="Page ?" class="navigation" href="#">Page ?</a>
                     <ul>
                        <li>
                           <a title="Page ?" class="navigation" href="#">Page ?</a>
                        </li>
                        <li>
                           <a title="Page ?" class="navigation" href="#">Page ?</a>
                           <ul>
                              <li>
                                 <a title="Page ?" class="navigation" href="#">Page ?</a>
                              </li>
                           </ul>
                        </li>
                     </ul>
                  </li>
               </ul>
            </li>
         </ul>
         <div class="clearer"><!--  --></div>
      </div>
      <div class="bottom"><!--  --></div>
   </div>
</div>

<div class="clearall"></div>

Extending Google Sitemap with Images and Language Versions

XperienCentral exposes three interfaces that make it possible to integrate images and content item language versions into Google Sitemap:

  • SEOGoogleSitemapFilterProvider
  • SEOGoogleSitemapImageProvider
  • SEOGoogleSitemapImageEnrichProvider

The following are examples of how to use each interface. See also the XperienCentral Javadoc for complete information on these interfaces.

SEOGoogleSitemapFilterProvider

This implementation excludes modular content items with a certain property from the sitemap. The rest of the code is a default service component.

Code Block
themeEclipse
public class SitemapRedirectFilterProviderServiceImpl extends SimpleServiceComponent implements SEOGoogleSitemapFilterProvider {
   // Logger for this class
   private static final Logger LOG = Logger.getLogger(SitemapRedirectFilterProviderServiceImpl.class.getName());

   @Override
   public boolean includeInGoogleSitemap(Website website, ContentItemVersion<?> contentItemVersion) {
      if(contentItemVersion instanceof ModularMediaItemVersion) {
         ModularTemplateInstance modularTemplateInstance = ((ModularMediaItemVersion) contentItemVersion).getModularTemplateInstance();
         if(modularTemplateInstance != null) {
            TemplateProperty redirectProperty = modularTemplateInstance.getPropertyByIdentifier("redirect_url");
            if(redirectProperty != null) {
               String redirect = redirectProperty.getStringValue();
               return StringUtils.isEmpty(redirect);
            }
         }
      }

      return true;
   } 
} 

SEOGoogleSitemapImageProvider

This implementation adds photos rendered in a media collection element to the sitemap.

Code Block
themeEclipse
public class SitemapImageProviderServiceImpl extends SimpleServiceComponent implements SEOGoogleSitemapImageProvider {
   @Override
   public List<SEOGoogleSitemapImage> getImages(ContentItemVersion<?> contentItemVersion) {
      List<SEOGoogleSitemapImage> images = new ArrayList<>();

      Element[] elements = new Element[0];
      if(contentItemVersion instanceof PageVersion) {
         elements = ((PageVersion) contentItemVersion).getElementHolderElements();
      } else if (contentItemVersion instanceof MediaItemVersion) {
         ElementHolder elementHolder = ((MediaItemVersion) contentItemVersion).getElementHolder();
            if(elementHolder != null) {
               elements = elementHolder.getElements();
            }
      }

      for (Element element : elements) {
         if (element instanceof MediaCollectionElement) {
            images.addAll(getImagesFromMediaCollectionElement((MediaCollectionElement) element));
         }
      }

      return images;
   }

   private List<SEOGoogleSitemapImage> getImagesFromMediaCollectionElement(MediaCollectionElement element) {
      List<SEOGoogleSitemapImage> images = new ArrayList<>();

      Presentation presentation = element.getPresentation();
      if(presentation != null && "mediaCollectionElementPhotoGallery".equals(presentation.getIdentifier())) {
         for(MediaItemVersion mediaItemVersion : element.getMediaItemVersions()) {
            if(mediaItemVersion instanceof ModularMediaItemImageVersion) {
               images.add(createSEOGoogleSitemapImageBean((ModularMediaItemImageVersion) mediaItemVersion));
            }
         }
      }

      return images;
   }

   private SEOGoogleSitemapImage createSEOGoogleSitemapImageBean(ModularMediaItemImageVersion mediaItemVersion) {
      if(mediaItemVersion.getImage() != null) {
         SEOGoogleSitemapImage seoGoogleSitemapImage = createSEOGoogleSitemapImageBean(mediaItemVersion.getImage());
         seoGoogleSitemapImage.setTitle(mediaItemVersion.getTitle());

         ModularTemplateInstance modularTemplateInstance = mediaItemVersion.getModularTemplateInstance();
         if (modularTemplateInstance != null) {
            seoGoogleSitemapImage.setCaption(modularTemplateInstance.getStringValue("caption"));
         }

         return seoGoogleSitemapImage;
     }

     return null;
  }

  private SEOGoogleSitemapImage createSEOGoogleSitemapImageBean(Image image) {
     SEOGoogleSitemapImage seoGoogleSitemapImage = new SEOGoogleSitemapImage();
     seoGoogleSitemapImage.setLoc(image.getAbsoluteUrl());

     return seoGoogleSitemapImage;
  }
} 

SEOGoogleSitemapImageEnrichProvider

This implementation adds a custom caption for the sitemap.

Code Block
themeEclipse
public class SitemapImageProviderServiceImpl extends SimpleServiceComponent implements SEOGoogleSitemapImageEnrichProvider {
   @Override
   public SEOGoogleSitemapImage enrichImage(SEOGoogleSitemapImage seoGoogleSitemapImage, ImageElement imageElement) {
      MediaItem mediaItem = imageElement.getMediaItem();
      if(mediaItem != null) {
         MediaItemVersion mediaItemVersion = mediaItem.getCurrent();
            if(mediaItemVersion instanceof ModularMediaItemImageVersion) {
               seoGoogleSitemapImage = createSEOGoogleSitemapImageBean((ModularMediaItemImageVersion) mediaItemVersion);
            }
         }

         return seoGoogleSitemapImage;
   }

   private SEOGoogleSitemapImage createSEOGoogleSitemapImageBean(ModularMediaItemImageVersion mediaItemVersion) {
      if(mediaItemVersion.getImage() != null) {
         SEOGoogleSitemapImage seoGoogleSitemapImage = createSEOGoogleSitemapImageBean(mediaItemVersion.getImage());
         seoGoogleSitemapImage.setTitle(mediaItemVersion.getTitle());

         ModularTemplateInstance modularTemplateInstance = mediaItemVersion.getModularTemplateInstance();
         if (modularTemplateInstance != null) {
            seoGoogleSitemapImage.setCaption(modularTemplateInstance.getStringValue("caption"));
         }

         return seoGoogleSitemapImage;
      }

      return null;
   }

   private SEOGoogleSitemapImage createSEOGoogleSitemapImageBean(Image image) {
      SEOGoogleSitemapImage seoGoogleSitemapImage = new SEOGoogleSitemapImage();
      seoGoogleSitemapImage.setLoc(image.getAbsoluteUrl());

      return seoGoogleSitemapImage;
   }
} 

Back to top


...

Forms
Anchor
forms
forms

Forms, just like other content elements, can be freely added to a page. The quantity and the type of input fields are flexible, however they need to be justified. The following items must have a design:

...