Sitecore – When You Are Not The Super User

Again I interact with Sitecore. This time because the project (still the same as before) is published in other server (not our server) and we have so limited access to it, I took liberty to create a small “Admin Panel”-like place for my client to get the data they need.

The basic requirement is simple. Our client just want to see the list of users that have been registered in their web. Before this page is exist, we tried to look on the after registration page through google analytics. Then it will cause us a lot of time and a lot of effort with a minimal result. Then the requirement come and as I have written earlier, they want to see the list of users.

The main thing in list of users must be email address, username, and registration date. The hardest yet still easy part to get is the registration date of every user. Basically, sitecore CMS automatically saved the registration date of every user. But, only those who are allowed that can see it in the back end. Since I am not the super admin, I made some modification on the way my users register. Using the code below, I can record the date of register.

newUser.Profile.SetCustomProperty("registerDate", DateTime.Now.ToString());

On the “Admin Panel” then use the code below.

List<User> listUser = Sitecore.Security.Accounts.UserManager.GetUsers().Where(o => o.Name.ToLowerInvariant().StartsWith("YourDomainName\\") && !o.Name.ToLowerInvariant().Contains("anonymous")).ToList();

aRepeater.DataSource = listUser;

Well, It is quite easy. But it bug me quite a short time to figure that up. The bad thing is that the custom property can only contains string. Means we can really use the date time easily. If you encounter the same requirement, please create the custom property from the start. Why? Because it is needed for the user custom property data to be recorded from the start. If you have already create a registration and encounter the same problem as me, doing the same method, then handle your exceptions well.

This custom property on user is quite useful too. One can store some things inside, as long as it is a string. Well, if you have other way to access it, then please share it 🙂

Sitecore – Shortening URL (for Your SEO Sake)

Hello, all! Tonight seems like the time for me to unleash what I have discovered during my time of blogging-hibernation. Earlier, I talked about WURFL and sitecore’s default way to detect device, now I talk about the way to shorten URL in Sitecore. This way bug me off and I left my question in stackoverflow left unanswered.

I am really aware that there is a default way for Sitecore to perform such task. What I found is my URL is really long and my boss is quite angry for it mess the SEO. Below is the default way.

UrlOptions opt = (UrlOptions)UrlOptions.DefaultOptions.Clone();
opt.SiteResolving = Sitecore.Configuration.Settings.Rendering.SiteResolving;
linkToResep.NavigateUrl = LinkManager.GetItemUrl(citem, opt);

Now, as you see, you need to configure the config too. So that it will shorten the URL as you wish. You can look on my question for detail.

I got various answers from kind people in my question, but, I still having trouble in it. So I am enlightened when my boss said that in PHP we can regex match something. Well, yeah! I will use regex to remove those long link!

As default we know that Sitecore LinkManager will produce a long link that contains /sitecore/content/sites/yoursite/ to access your items. Well, it seem so suck to the SEO. Then we should remove it. Below is how.

  1. Create a link using Sitecore.Links.LinkManager.GetItemURL(myItem). The output will be used as a parameter to my method that will shorten the url.
  2. Create a method that will receive a link and will shorten it for sure. I suggest you to create a helper class that will contain all functions and helpful methods that you need in many classes.
    public static string ShortenURL(string URLToShorten)
        return Regex.Replace(URLToShorten,@"sitecore/content/sites/[\w]{1,}/","");
  3. The call will be like below.
    yourHyperLinkObject.NavigateUrl = your.helper.ShortenURL(Sitecore.Links.LinkManager.GetItemURL(myItem));

Well, I tested it already, and thank you to the regexpal that ease my testing.

Wait, wait, wait, wait. Hold on! That easy? Yes. Why I didn’t find it out so quickly? Well, people, I didn’t think out of the box. I was when I found this out through my boss’ words about PHP. Okay, problem solved? Not yet! Look on the title, for your SEO sake. We just shorten the URL and not finished optimizing the SEO.

If you are Sitecore developer, then you must have known that you can access your site using both and Okay, you knew it already, then what about it. As soon as I can shorten the URL, my boss feel relieved, and he asked whether the old long link still accessible or not. I said, yes. He panicked!

What must I do, first, you need to add canonical to your site tag. The canonical will contains the long link. Second, if you must, you need to put a redirection whenever someone is trying to access the long link to the correct short link.

Using this, well, your SEO is getting better and not screwed up a lot. I hope this is useful to you all folks! Please feel free to comment 🙂

Sitecore – WURFL or Sitecore Device Default Detection

Hi all! I return from my long blogging-hibernation. Lately, I encounter a little problem with mobile detection in Sitecore. Before that, yes, I am still working on the website of my company’s client and yes, though I really tired of this Sitecore stuffs, I still feel so curious about it. I hope through this post, you can find the best way to choose for your Sitecore site in detecting device.

As we know, WURFL is a powerful tool that makes your web page suit the device that opens it. We also know that Sitecore is powerful enough to let the developers set a different look and feel for a different device. I thanked so much to my client for they have provided us, the developers a good-customized-WURFL-system. Our client, that is mainly based in the continent far away customized the 51Degree to suit their needs. I don’t want to write how to do such because greater people than me have written about it in their blog (example: the great mentor – at least for me – Alex’s blog.)

Then using the module that our client have made, we can differentiate the site look and feel on various devices. Well, for now, we just differ between mobile, tablet, and our beloved big screen computer. Well, it works just great. Our client make a fine module and I like it! Well, somehow there is a problem, what if the device have a different user agent and that user agent is not registered, yet? Also the update can be automatically done.

In contrast, you know that most of the devices have a common thing in their user agent. Really? What is it? For example, there will be words like “mobile”, “Blackberry”, “Android”, “iP”, etc. You can add the devices and don’t have to write a module like what my client have done. It can detect automatically, and easily. Really? Yes. So, I tried this, too! The result is just great! Fine and really nice. The goodness is that you can detect most of devices easily because they “must have something in common” on their user agent. What’s the disadvantage? If you add a new device, well, be sure to update all of the items in your Sitecore, which can be so many even though you only update the default value of the template.

In the last two paragraphs, it shows like I am telling you that Sitecore default device detection using user agent is a classic way that cost us more effort than using the WURFL way to detect device. Well, I’m afraid I have to say that is true. Since 51Degree offers a free lite package to use, we can just create a module that will need to be updated once or twice for a long time. We don’t have to really create a new device and trouble us with all the task to assign the layouts and sub-layouts to our Sitecore items.

Well, it is up to you to choose. But I am sure there are more things to consider than just what I wrote in here. Be free to comment.

May, 29 2013 update:
For some reason, the device detection system on my local is having problem. Sometimes it works out, sometimes it don’t. I tried to check the values of IsMobile and width (these two rules are those who are used in detecting mobile device in my project). It shows values that match the rule, but somehow it keeps showing the default layout setting from Sitecore. Will update on the way to prevent it.

Orchard – Slow?

Hello! I’m back!

Lately there was an issue related to a site that I have published. It was using Orchard 1.4.1 and it is (the client think) is slow. I am confused for the first when I face the issue. “It is running so fast in my computer!”, I said. But then it was a client and of course, they didn’t accept such reason.

Then I began to browse for the solutions and I got some as described below.

  1. Maintain the server performance (IIS) on this Orchard documentation, I found that some steps may be taken. Managing App Pool Recycle can be useful too. 🙂
  2. Updating your Orchard. This discussion clearly describe that updating orchard can make the site runs faster.
  3. I reference back to the first link. Removing the unused modules. I was using Disqus for the website’s comment system. What I got is a complaint from the client for their web is so slow. I can’t blame them for the slow connection. Disqus load outside files and data. Then I try to calm them down using normal comment from Orchard and it runs a bit faster. Well, not quite a good decision for I have to implement some more functions so that the Orchard.Comments will act like Disqus. Fool indeed.

That’s the three maintenance that I have done. I think the site runs quite faster now. I hope they like it.

phpBB Cant find styles data problem

Hi all! It’s a short time from my last post. I was an admin at a local forum for students and I was not alone. A friend of mine helped me as an admin and it made us two the prime admin. Somehow, today, he managed to add a theme but it gone being a mess. Suddenly all things went bad and error page pop out in all pages.

The error message is simple. Cannot find styles data. The reason was that my forum was having a trouble finding the appropriate data for the styles. Have you ever found similar errors? Well that was my first time. Those helps on forums I think did a little thing to save me from this little catastrophe. Forums kept saying that you should remove the files in cache and be free. I told not just that. Below are the steps.

  1. go to database and choose config table
  2. edit the default theme value into one available on your platform. Well, choose one from styles table

It is the first way. If it still not effective, set the file permission in styles folder to 755 and then delete all files in the cache folder.

If it still not useful, try to rename the working theme directory to the name of your broken theme and delete your old broken theme directory.

That’s it. Your forum should look great with themes. Glad to help.

XML (2)

Setelah lama ga posting, akhirnya saya kembali! 😀

Ternyata oh ternyata, ada yang lain dengan XML. Ternyata format untuk XML bisa ditentukan. Jadi stuktur datanya jelas. Nah, gimana caranya? Itulah makanya ada DTD dan XML Schema.

Kemarin aku dikasi software Altova XMLSpy sama dosen aku untuk praktikum. Nah software itu membantu sekali untuk membuat XML Schema dan DTD karena memang ada fitur auto generatenya. Tapi sebaiknya jangan pakai itu dulu.

DTD dan XML Schema itu memang digunakan untuk menetapkan apa isi file XML seharusnya. Tapi keduanya berbeda di sintaks dan penggunaan.

DTD itu memang mendefinisikan, namun ga pakai tipe untuk tiap variabelnya. Misalkan aja untuk DTD kita ga nentuin apakah itu string, integer atau yang lain.

Berbeda dengan DTD, xml schema masih sedikit dipakai dan sintaksnya juga lain sekali. Xml schema jelas tampak mampu mendefinisikan tipe variabel untuk file xml. Jadi semakin nampak xml itu sebagai struktur data.

Okay, demikian dlu untuk sekarang. Semoga berguna. Kalau untuk syntax dan lainnya, saya rasa saya tidak perlu menuliskan di sini karena sudah cukup lengkap diberikan w3school. 🙂

have a nice day… See ya!

sesekali post tentang PHP

PHP = ???

Ga tau dan banyak situs memanjangkannya. Bagiku, PHP itu tool. Alat untuk bangun web. Aku ga terlalu peduli dengan gimana dia komunikasi atau gimana, yang jelas aku punya PHP untuk membangun web yang aku ingini (ga semua terwujud sih).

Apa yang buat PHP gitu? Nah PHP itu kan teknologi. Dengannya kita bangun Web Based Application. App mana juga yang ga dibangun dengan bahasa tertentu? Gadak kan? PHP kenapa dipakai? Karena dia memungkinkan thin client.

Thin client itu apa? Thin = kurus client = client. Ga gitu juga. Artinya client dengan kemampuan sedikit. Maksudnya sisi client ga mampu proses besar besar. Dengan PHP, si client hanya perlu minta Server laukin sesuatu dan terima hasil. Ga pake proses di clientlah (tergantung sama programmernya).

Kalau udah gitu, kan clientnya ga perlu banyak nih. Permasalahannya ada di bandwidth dong! Yah urus sama mas admin lo sana….

Terus apa lagi? Nah, fitur utama yang paling melekat di hati penggunanya sejak kecemplung ke dunia IT, PHP itu membuat protokol http jadi punya state (keadaan). Maksudnya wak?

Gini, kalo kita jalan jalan di Internet, kan ga ada keadaan yang diketahui oleh satu halaman lain dari halaman sebelumnya. Keadaan itu ganti ganti aja seiring kita keliling web. Apa sih keadaan? Keadaan itu yah variabel yang muncul/ada ketika kita main main di satu page. Misal user ID atau apalah. Kok bisa gitu? Yah terima kasih untuk PHp atas cookie dan sessionnya!

Wow! Paling ena makan chocolate cookie pas winter season nih. Ga gitu. Cookie itu yah metoda. Dia nyimpan isi state itu ke dalam sebuah file. File itu nantinya dipake si browser untuk melihat keadaan. Cookie ini kadang ga berfungsi kalo di disable 😀 isinya antara lain yah nama cookie, value, web-site, lama hidup cookie, dll.

Session itu, adekannya cookie atau anaknya cookie (ga jelas sih, ga baca tarombo). Session itu lebih flexible, tapi ga selalu terjamin. Kenapa? Dia kerja di sisi server, terus dia ga kejumpa lagi kalau udah off atau udah di destroy yanh ilang aja gitu. : poof! :

Posted with WordPress for BlackBerry.