close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How to make details page link have title of the page instead of number ie ?id=1,2,3.......

Thread began 9/13/2014 6:23 pm by Kumel | Last modified 12/29/2014 3:23 pm by Ray Borduin | 1861 views | 25 replies |

Kumel

How to make details page link have title of the page instead of number ie ?id=1,2,3.......

I had created a blog using dataassist. everything seem fine except the link. i tried a lot but unable to do it. please can anyone help me out in detail with this?

Required files attached. screenshot of DB also attached.


Regards

Sign in to reply to this post

Kumel

previous screenshot of db might be confusing to understand as db name was blog as well as table name. Now i have changed Db name to "wenger" & table as "blog" itself.

Sign in to reply to this post

Jamie

Hey Kumel

I thought I would create a tutorial for this so have written it up (tutorial not yet submitted) but hopefully this will help you. I have had to make certain assumptions so if any step needs clarification please drop me a line.

In the first place you need to add a new column to your 'blog' table - lets call the new column 'Permalink' and set it to varchar like you have set the 'title' column.

Permalink will store the SEO friendly part of the URL and we will get the _insert or _results pages to change a title from this format 'This is the blog title' to 'this_is_the_blog_title' - you can see an example of that here http://www.motley.co.uk/blog-article/Dont-let-bootstrapping-lead-to-handcuffing

Once you have added that column to the table, we need to open up the blog _insert and _update pages (I am not sure what you have named them)

On the _update page you need to click on 'Update Record' that you find in the server behaviours area. In the resulting Data Assist pop up window you should have 2 tabs: General and Bindings - click on 'Bindings' and look for the column named 'Permalink' that we created at the beginning. When you find it, highlight it, set the type to 'text' and then click on the lightning bolt. A new window will open which allows you to bind the form elements to the relevant columns. Bind the entry called 'title' (using your column name) - when you select the binding it should look like this <?php echo((isset($_POST["title"]))?$_POST["title"]:"") ?>

Click OK, and then OK again

Now, in the code view of the page you need to navigate to the Update Record which you can get to quickly by clicking the same in the server behaviours. In this area there will be 2 instances of the following:

$WA_AB_Split . "".((isset($_POST["title"]))?$_POST["title"]:"")  ."" .



change the 2nd instance to this:

$WA_AB_Split . "".((isset($_POST["title"]))?preg_replace('/[^0-9a-z(),]/i','-',str_replace(array("’ ","br ","<",">","' ","%","!","?","@","\-","- ","/ ",".","\"","_","– ","\'","*","#","+ "),"",strtolower(stripslashes(str_replace("&", "and", str_replace("é", "e", $_POST["title"])))))):"")  ."" .



This is basically to take whatever the user enters in as a title (eg This is a blog post) and changes it to this_is_the_blog_post

Now you need to do the same for the _insert page. (Update Record will be Insert Record etc)

The back end is now all set and we just need to address the .htaccess file which does the mod_rewriting and change the front end so that the new SEO friendly URL will display instead of ?id=1,2,3....... etc

In the front end you should have 2 blog pages. One shows the results of all blog posts (lets call this one blog.php) and the other is the one that displays the content of each blog article (lets call this one blog-article.php)

Lets open up blog.php.

Here I am making the assumption that your recordset is named 'Blog' - if it isnt, just change the rs references to whatever you have called it.

On blog.php we need to change the link structure from something that looks like this:

<a href="blog-article.php?BlogID=<?php echo($Blog->getColumnVal("BlogID")); ?>"> <?php echo($Blog->getColumnVal("BlogTitle")); ?></a>



the onpage url structure for the above would be /blog.php?BlogID=1,2,3...etc

to this:

<a href="article/<?php echo $Blog->getColumnVal("Permalink"); ?>"> <?php echo $Blog->getColumnVal("title"); ?></a>



the onpage url structure for this would look something like this /article/this_is_a_blog_post

Now lets open up blog-article.php

On this page we need to change the recordset so that the page is able to render the correct page based on the mod_rewrite that we will be doing in the .htaccess file at the end of this.

The recordset that you use to access the blog data needs to loo like this:
(if you're using MySQLi)

<?php
$Blog = new WA_MySQLi_RS("PageContents",$DBConnection,1);
$Blog->setQuery("SELECT * FROM blog WHERE id = ? OR Permalink = ?");
$Blog->bindParam("i", "".(isset($_GET['id'])?$_GET['id']:"") ."", "-1"); //paramOffersID
$Blog->bindParam("s", "".(isset($_GET['perm'])?$_GET['perm']:"") ."", "-1"); //paramPermalink
$Blog->execute();
?>



(if you're using MySQL)

<?php
$colname_BlogPerm = "-1";
if (isset($_GET['perm'])) {
$colname_BlogPerm = $_GET['perm'];
}
$colname_Blog = "-1";
if (isset($_GET['id'])) {
$colname_Blog = $_GET['id'];
}
mysql_select_db($database_PowerCMSConnection, $PowerCMSConnection);
$query_Blog = sprintf("SELECT * FROM blog WHERE id = %s OR Permalink = %s", GetSQLValueString($colname_Blog, "int"), GetSQLValueString($colname_BlogPerm, "text"));
$Blog = mysql_query($query_Blog, $PowerCMSConnection) or die(mysql_error());
$row_Blog = mysql_fetch_assoc($Blog);
$totalRows_Blog = mysql_num_rows($Blog);
?>



Also on the blog-article.php page because we are changing the directory structure on the fly, we need to tell the page what the root of the site is so that it is able to reference all the files correctly. To do this, add this just after the opening <html> tag

on a local server: <base href="http://localhost/foldername/" />
on a live page: <base href="http://www.domainname.co.uk/" />

don't forget the trailing / in either of those examples

Save the blog.php and blog-article.php pages if you havent already done so.

Now we need to create the rewrite in the .htaccess file.

All you now need to do is create (or edit if you already have one) using the following code.

RewriteEngine on

RewriteRule ^article/(.*)$ blog-article.php?perm=$1 [NC,L,QSA,T=application/x-httpd-php]



Save and upload

Save that and now upload all the files and you should have a similar set up to the one found at http://www.motley.co.uk/blog.php

I hope that this helps but if you need any help or clarification please do let me know

All the best

Jamie

Sign in to reply to this post

Kumel

Its in my local server.
it a simple thing. i created data assist page. now on result page when i click particular item or blog or so then link is detail.php?id=1 , 2 , 3 & etc.

It is the ID which is linked to & is link is displayed as ID. i want title to be displayed.

Regards

Sign in to reply to this post

Jamie

looks like we cross posted.. see my post above yours

Jamie

Sign in to reply to this post

Kumel

:) Let me try it!
Will revert back as soon as possible
Thank You

Sign in to reply to this post

Kumel

i understood most of the above thing but confused here:
***
On the _update page you need to click on 'Update Record' that you find in the server behaviours area. In the resulting Data Assist pop up window you should have 2 tabs: General and Bindings - click on 'Bindings' and look for the column named 'Permalink' that we created at the beginning. When you find it, highlight it, set the type to 'text' and then click on the lightning bolt. A new window will open which allows you to bind the form elements to the relevant columns. Bind the entry called 'title' (using your column name) - when you select the binding it should look like this <?php echo((isset($_POST["title"]))?$_POST["title"]:"") ?>



***
right now in front of me i have update page open. i first went to server behaviours & clicked "update record". Now i choosed key column as permalink & value as <?php echo ((isset($_POST["title"]))?$_POST["title"]:""); ?> & data type is text.

After that i clicked finish. Now i cant not find anything as $WA_AB_Split . "".((isset($_POST["title"]))?$_POST["title"]:"") ."" .

Following is my update record code:




<?php
// WA Application Builder Update
if (isset($_POST["Update"])) // Trigger
{
$WA_connection = $con1;
$WA_table = "blog";
$WA_redirectURL = "admin.php";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_indexField = "permalink";
$WA_fieldNamesStr = "title|short_description|long_description|img|img_thumb|img2|img3|date|month|year|author|category|editor|ref|keywords";
$WA_fieldValuesStr = "".((isset($_POST["title"]))?$_POST["title"]:"") ."" . "|" . "".((isset($_POST["short_description"]))?$_POST["short_description"]:"") ."" . "|" . "".((isset($_POST["long_description"]))?$_POST["long_description"]:"") ."" . "|" . "".((isset($_POST["img"]))?$_POST["img"]:"") ."" . "|" . "".((isset($_POST["img_thumb"]))?$_POST["img_thumb"]:"") ."" . "|" . "".((isset($_POST["img2"]))?$_POST["img2"]:"") ."" . "|" . "".((isset($_POST["img3"]))?$_POST["img3"]:"") ."" . "|" . "".((isset($_POST["date"]))?$_POST["date"]:"") ."" . "|" . "".((isset($_POST["month"]))?$_POST["month"]:"") ."" . "|" . "".((isset($_POST["year"]))?$_POST["year"]:"") ."" . "|" . "".((isset($_POST["author"]))?$_POST["author"]:"") ."" . "|" . "".((isset($_POST["category"]))?$_POST["category"]:"") ."" . "|" . "".((isset($_POST["editor"]))?$_POST["editor"]:"") ."" . "|" . "".((isset($_POST["ref"]))?$_POST["ref"]:"") ."" . "|" . "".((isset($_POST["keywords"]))?$_POST["keywords"]:"") ."";
$WA_columnTypesStr = "',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''";
$WA_comparisonStr = "=|=|=|=|=|=|=|=|=|=|=|=|=|=|=";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);

$WA_where_fieldValuesStr = "".((isset($_POST["title"]))?$_POST["title"]:"") ."";
$WA_where_columnTypesStr = "',none,''";
$WA_where_comparisonStr = "=";
$WA_where_fieldNames = explode("|", $WA_indexField);
$WA_where_fieldValues = explode("|", $WA_where_fieldValuesStr);
$WA_where_columns = explode("|", $WA_where_columnTypesStr);
$WA_where_comparisons = explode("|", $WA_where_comparisonStr);

$WA_connectionDB = $database_con1;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$updateParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WhereObj = WA_AB_generateWhereClause($WA_where_fieldNames, $WA_where_columns, $WA_where_fieldValues, $WA_where_comparisons );
$WA_Sql = "UPDATE `" . $WA_table . "` SET " . $updateParamsObj->WA_setValues . " WHERE " . $WhereObj->sqlWhereClause . "";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>


Thank You

Sign in to reply to this post

Jamie

It doesn't look like you have actually updated the 'Update Record' (although your first edit of your reply did show that it had been uodates

Looking at your code , this

$WA_fieldNamesStr = "title|short_description|long_description|img|img_thumb|img2|img3|date|month|year|author|category|editor|ref|keywords";
$WA_fieldValuesStr = "".((isse t($_POST["title"]))?$_POST["title"]:"") ."" . "|" . "".((isset($_POST["short_description"]))?$_POST["short_description"]:"") ."" . "|" . "".((isset($_POST["long_description"]))?$_POST["long_description"]:"") ."" . "|" . "".((isset($_POST["img"]))?$_POST["img"]:"") ."" . "|" . "".((isset($_POST["img_thumb"]))?$_POST["img_thumb"]:"") ."" . "|" . "".((isset($_POST["img2"]))?$_POST["img2"]:"") ."" . "|" . "".((isset($_POST["img3"]))?$_POST["img3"]:"") ."" . "|" . "".((isset($_POST["date"]))?$_POST["date"]:"") ."" . &quo t;|" . "".((isset($_POST["month"]))?$_POST["month"]:"") ."" . "|" . "".((isset($_POST["year"]))?$_POST["year"]:"") ."" . "|" . "".((isset($_POST["author"]))?$_POST["author"]:"") ."" . "|" . "".((isset($_POST["category"]))?$_POST["category"]:"") ."" . "|" . "".((isset($_POST["editor"]))?$_POST["editor"]:"") ."" . "|" . "".((isset($_POST["ref"]))?$_POST["ref"]:"") ."" . "|" . "".((isset($_POST["keywords"]))?$_POST["keywords"]:"") ."";
$WA_columnTypesStr = "',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none, ''|',none,''|',none,''|',none,''|',none,''|',none,''";
$WA_comparisonStr = "=|=|=|=|=|=|=|=|=|=|=|=|=|=|=";



Should be

$WA_fieldNamesStr = "title|short_description|long_description|img|img_thumb|img2|img3|date|month|year|author|category|editor|ref|keywords|permalink";
$WA_fieldValuesStr = "".((isse t($_POST["title"]))?$_POST["title"]:"") ."" . "|" . "".((isset($_POST["short_description"]))?$_POST["short_description"]:"") ."" . "|" . "".((isset($_POST["long_description"]))?$_POST["long_description"]:"") ."" . "|" . "".((isset($_POST["img"]))?$_POST["img"]:"") ."" . "|" . "".((isset($_POST["img_thumb"]))?$_POST["img_thumb"]:"") ."" . "|" . "".((isset($_POST["img2"]))?$_POST["img2"]:"") ."" . "|" . "".((isset($_POST["img3"]))?$_POST["img3"]:"") ."" . "|" . "".((isset($_POST["date"]))?$_POST["date"]:"") ."" . &quo t;|" . "".((isset($_POST["month"]))?$_POST["month"]:"") ."" . "|" . "".((isset($_POST["year"]))?$_POST["year"]:"") ."" . "|" . "".((isset($_POST["author"]))?$_POST["author"]:"") ."" . "|" . "".((isset($_POST["category"]))?$_POST["category"]:"") ."" . "|" . "".((isset($_POST["editor"]))?$_POST["editor"]:"") ."" . "|" . "".((isset($_POST["ref"]))?$_POST["ref"]:"") ."" . "|" . "".((isset($_POST["keywords"]))?$_POST["keywords"]:"") ."" . "|" . "".((isset($_POST["title"]))?$_POST["title"]:"") ."";
$WA_columnTypesStr = "',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none, ''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''";
$WA_comparisonStr = "=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=";
Sign in to reply to this post

Kumel

its confusing now. lets go step by step. currently on my update page this is my update behaviour code:

<?php
// WA Application Builder Update
if (isset($_POST["Update"])) // Trigger
{
$WA_connection = $con1;
$WA_table = "blog";
$WA_redirectURL = "admin.php";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_indexField = "permalink";
$WA_fieldNamesStr = "title|short_description|long_description|img|img_thumb|img2|img3|date|month|year|author|category|editor|ref|keywords|permalink";
$WA_fieldValuesStr = "".((isset($_POST["title"]))?$_POST["title"]:"") ."" . "|" . "".((isset($_POST["short_description"]))?$_POST["short_description"]:"") ."" . "|" . "".((isset($_POST["long_description"]))?$_POST["long_description"]:"") ."" . "|" . "".((isset($_POST["img"]))?$_POST["img"]:"") ."" . "|" . "".((isset($_POST["img_thumb"]))?$_POST["img_thumb"]:"") ."" . "|" . "".((isset($_POST["img2"]))?$_POST["img2"]:"") ."" . "|" . "".((isset($_POST["img3"]))?$_POST["img3"]:"") ."" . "|" . "".((isset($_POST["date"]))?$_POST["date"]:"") ."" . "|" . "".((isset($_POST["month"]))?$_POST["month"]:"") ."" . "|" . "".((isset($_POST["year"]))?$_POST["year"]:"") ."" . "|" . "".((isset($_POST["author"]))?$_POST["author"]:"") ."" . "|" . "".((isset($_POST["category"]))?$_POST["category"]:"") ."" . "|" . "".((isset($_POST["editor"]))?$_POST["editor"]:"") ."" . "|" . "".((isset($_POST["ref"]))?$_POST["ref"]:"") ."" . "|" . "".((isset($_POST["keywords"]))?$_POST["keywords"]:"") ."" . "|" . "".((isset($_POST["title"]))?$_POST["title"]:"") ."";
$WA_columnTypesStr = "',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''";
$WA_comparisonStr = "=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);

$WA_where_fieldValuesStr = "".((isset($_POST["title"]))?$_POST["title"]:"") ."";
$WA_where_columnTypesStr = "',none,''";
$WA_where_comparisonStr = "=";
$WA_where_fieldNames = explode("|", $WA_indexField);
$WA_where_fieldValues = explode("|", $WA_where_fieldValuesStr);
$WA_where_columns = explode("|", $WA_where_columnTypesStr);
$WA_where_comparisons = explode("|", $WA_where_comparisonStr);

$WA_connectionDB = $database_con1;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$updateParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WhereObj = WA_AB_generateWhereClause($WA_where_fieldNames, $WA_where_columns, $WA_where_fieldValues, $WA_where_comparisons );
$WA_Sql = "UPDATE `" . $WA_table . "` SET " . $updateParamsObj->WA_setValues . " WHERE " . $WhereObj->sqlWhereClause . "";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>

Sign in to reply to this post

Jamie

That looks correct

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...