• Welcome to KonaKart Community Forum. Please login or sign up.
 

Unique Title and meta description for each page for SEO

Started by bibi, October 04, 2012, 12:39:48 pm

Previous topic - Next topic

bibi

Hi All,

Is there any easy way to implement this unicity (Unique Title and meta description for each page for SEO )for each page of the website?

Thanks

PS:i'm using the konakart 4.2

bibi


bibi

Hi

I've found a way to do it without much effort, i didnt take time to test all the pages (if problems i will update the post) i would like to share it with you all

1 Change the getKKAppEng() function of the BaseAction.java
2 Modify de setPageTitle(), setMetaDescription(), setMetaKeywords() functions with the following
        kkAppEng.setPageTitle(getCatMessage(request, kkAppEng.getPageTitle()));
        kkAppEng.setMetaDescription(getCatMessage(request, kkAppEng.getMetaDescription()));
        kkAppEng.setMetaKeywords(getCatMessage(request, kkAppEng.getMetaKeywords()));
3 Recompile

4 Adding on the current JSP the following portion of code
will do the job
       <% kkEng.setPageTitle("my.titleforthecurrentjsp");%>
my.titleforthecurrentjsp is the index key of the message catalog u want to set


I didnt check yet the meta keywords, but i will update if any problem detected

It take some time for the generated class to stabilize for the accurate  title, but it work fine now



PS: problem may arise on the performance side, i will check that too

Best regards

bibi

Sorry for misguidance

only this on each struts action class called by the jsp is enough and functional

1 Modify de setPageTitle(), setMetaDescription(), setMetaKeywords() functions with the following
        kkAppEng.setPageTitle(getCatMessage(request, "seo.mytitle.title"));
        kkAppEng.setMetaDescription(getCatMessage(request, "seo.mydescription.description"));
        kkAppEng.setMetaKeywords(getCatMessage(request, "seo.mykeywords.keywords"));
2 Recompile
3 replace your konakart_custom.jar from the /lib

lrkwz

Sorry but I cannot understand your solution: you are simply using

seo.mytitle.title
seo.mydescription.description
seo.mykeywords.keywords

instead of:

seo.default.title
seo.default.meta.description
seo.default.meta.keywords

for ALL the pages isn'it?

lrkwz

I resolved this issue defining



       private String getCatMessage(HttpServletRequest request, String path,
                        String key) {
                final String localKey = String.format("seo.%s.%s", path, key);
                String localMessage = getCatMessage(request, localKey);
                if (localMessage.contains(localKey)) {
                        log.debug("Resources for " + localKey
                                        + " not found searching seo.default." + key);
                        localMessage = getCatMessage(request, "seo.default." + key);
                }
                log.debug("Resource value is:" + localMessage);
                return localMessage;
        }

        protected KKAppEng getKKAppEng(HttpServletRequest request,HttpServletResponse response, String path) throws KKAppException,
                        KKException {
                KKAppEng kkAppEng = super.getKKAppEng(request, response);

                kkAppEng.setPageTitle(getCatMessage(request, path, "title"));
                kkAppEng.setMetaDescription(getCatMessage(request, path,
                                "meta.description"));
                kkAppEng.setMetaKeywords(getCatMessage(request, path, "meta.keywords"));

                return kkAppEng;

        }


where getKKAppEng(HttpServletRequest request,HttpServletResponse response, String path) must be called from the execute method in your actions


        public ActionForward execute(ActionMapping mapping, ActionForm form,
                        HttpServletRequest request, HttpServletResponse response) {

                try {
                        int custId;

                        KKAppEng kkAppEng = this.getKKAppEng(request, response, mapping.getPath().substring(1));
...


In this way you can define special custom title on a pre-path basis in Message.properties.