Page 1 of 1

Simple questions (probably)

Posted: Fri Dec 15, 2006 5:05 pm
by Cakkie
Hi, I'm converting a semi-static website to CMSMS, but for that I need to write a few custom modules. I'm new to module design and I have just started development of my first module, starting from the Skeleton module. The front-end of the module is nearly complete, but I have a few annoyances I want to get rid of.

To start, here's a link to the actual module as it currently is:
http://www.funpages.be/pokerama/index.php?p=woordenboek

The site is in dutch, but you can see what the module does. It has a list of words (stored in a database table) and when clicked you will be sent to a page showing the meaning for that word.

At the top of the page, there's a list of shortcuts using the first character of the words. The goal is that when a user presses a starting character, it jumps down the page to the specified anchor. All anchors are in place, I'm just having a bit of trouble with getting the links correct. I'm just linking to #character, but appearantly I get sent to /#character rather than /index.php?p=currentpage#character. How can I make a link to the same page the user is currently on? I assume I will need to get the pagealias and the name of the page variable i choose when installing (in this case "p" rather than the default "page"). Any pointers on where to find these values?

A second, somewhat related issue, is that when views a detail page, there's a link to return to the previous page. I'm using the createlink function to do this, using the id of the module. It would be nicer though if I would simply link back to ?p=woordenboek instead. Again I'll probably need the name of the page, and the name of the page variable.

And last, since where's at it anyway, I'd like to use a form of pretty urls for the urls of the detail pages. It should look like:

index.php?p=woordenboek&word=word

The reason I want exactly that format, is because the current site is using that format as well, and I want to keep any incoming links or search engine listings working.

Any help is appreciated

Tom

Re: Simple questions (probably)

Posted: Fri Dec 15, 2006 5:25 pm
by cyberman
Cakkie wrote: To start, here's a link to the actual module
Looks nice - perhaps you can release it on CMSms ForgeĀ  :) ...

Re: Simple questions (probably)

Posted: Fri Dec 15, 2006 10:44 pm
by Dee
Are you using the CMSModule CreateLink method to generate the character links? In that case you can simply send the selected character as a (new) parameter.
Getting the current page link is a bit tricky, I use this code in Guestbook:

Code: Select all

	/**
	 * Returns the current URL
	 * @return string
	 */
	function GetURL()
	{
		$config = $this->cms->config;
		$url = "";
		if ($config['assume_mod_rewrite'])
		{
			$url = $config['root_url'] . '/' . $this->cms->variables['page'];
			$url .= $config['page_extension'];
		}
		else
		{
			$url = $config['root_url'] . '/index.php?' . $config['query_var'] . '=' . (isset($this->cms->variables['page']) ? $this->cms->variables['page'] : '');
		}
		return $url;
	}
Regards,
D

Re: Simple questions (probably)

Posted: Fri Dec 15, 2006 11:18 pm
by Cakkie
Ok, for now I'm not going to go for support for pretty url's, since it seems a bit tricky, and there are more important things to do.

The links to the #anchors are not made using CreateLink, since they are mearly simple references to anchors within the same page (so normally, there should not be a server reload). I found the page name in $gCms->variables["page_name"], and $gCms->config["query_var"] tells me what name to use as page parameter.

In an effort to get the urls match the current site, I did a little hack and added the $_GET["word"] to params myself, but this is something specific to the site, so that's not going to be part of the eventual release, wich will be coded "the right way" ;)

Anyway, next thing on my list is the admin section, but that's something for next week, when I have a little more time.

Re: Simple questions (probably)

Posted: Sun Dec 17, 2006 4:32 pm
by brady
Cakkie wrote: At the top of the page, there's a list of shortcuts using the first character of the words. The goal is that when a user presses a starting character, it jumps down the page to the specified anchor. All anchors are in place, I'm just having a bit of trouble with getting the links correct. I'm just linking to #character, but appearantly I get sent to /#character rather than /index.php?p=currentpage#character. How can I make a link to the same page the user is currently on?
First thing, this isn't anything your module did. The problem is in your template. In your template for that page you probably have {metadata} used somewhere. If you read the help for metadata it says that it automatically adds a tag. Just turn {metadata} into {metadata showbase='false'}. That MAY cause other problems though.