Permalinks 1.02 Questions / Help

By Dave - November 28, 2013

Hi Andy, 

Sorry for the delay in responding.  

My question is, am I able to add free text into the first list to get the Permalink to display exactly as I would like. I have used CAPITALS in the code below to show where I would like the free text to go:-

No, there's no support for that, but it's a really interesting idea.  Can you show me some examples of the types of URLs you'd like to have automatically created?   There's some SEO unfriendly words (in, with, etc) that would be best removed, but being able to add custom text (even slashes) would make some interesting things possible.

2) I am having a problem with Automatically Redirecting Old Links to Permalinks.

Try moving the function just under the $listing line and changing the variable passed from $listingRecords to $listing (new code in red):

$listing = @$listingRecords[0];
<?php permalinks_301redirectToPermalink($listing); ?>

Let me know if that works for you.  Thanks!

Dave Edis - Senior Developer
interactivetools.com

Hi Dave

With reference to point 2

I put the code where you suggested but it came up with a syntax error.

I therefore changed the code slightly to the code below in red, ( still moving the redirect code up the page as you suggested) but it still did not work.

Any more ideas?

Thanks

Andy

<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block to the TOP of your page BEFORE anything else. */
  require_once "init.php";

  list($listingRecords, $listingDetails) = getRecords(array(
    'tableName'   => 'listings',
    'joinTable'   => 'homepages',
    'where'       => whereRecordNumberInUrl(1),
    'limit'       => '1',
  ));
  $listing = @$listingRecords[0];
 

 if (!$listing) { print "Listing not found!"; exit; }
 
 ?>

  <?php permalinks_301redirectToPermalink($listing); ?>

 <?php
// ++++++++++++++
// Get Page URL
// +++++++++++++++
include("../selfURL.php");
$work_url = (selfURL());
// echo $work_url; // Only used for testing BUT $work_url can be placed in code

?>

Hi

Just to let you know that the Permalinks are now working - thanks!

Not sure what the problem was before, I removed a few line breaks and tried again using your permalink redirect code and now works really well.!

The code now looks like this

<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block to the TOP of your page BEFORE anything else. */
  require_once "init.php";

  list($listingRecords, $listingDetails) = getRecords(array(
    'tableName'   => 'listings',
    'joinTable'   => 'homepages',
    'where'       => whereRecordNumberInUrl(1),
    'limit'       => '1',
  ));
  $listing = @$listingRecords[0];


  if (!$listing) { print "Listing not found!"; exit; }
?>
<?php permalinks_301redirectToPermalink($listing); ?>
<?php
// ++++++++++++++
// Get Page URL
// +++++++++++++++
include("../selfURL.php");
$work_url = (selfURL());
// echo $work_url; // Only used for testing BUT $work_url can be placed in code

?>

Regarding my first point, I have also managed to include some free text by creating some extra fields in the database for these. I then include them in my string on line 11 of the permalinks.php file. This line now looks like this (free text fields in red):-

$GLOBALS['PERMALINKS']['autopopulate_fromFields'] = array('property_type for_sale_in town bedrooms beds reference_number', 'title'); // the first field in this list with content will be used to create the permalinks. To use multiple fields separate them with spaces

This gives me a URL of  /villa-for-sale-in-benitachell-3-beds-kjvs183/

You may notice that I am outputting "for" and "in" in the URL. I wanted to do this because it makes the URL more descriptive. To do this I removed these 2 words from line 12 so it is now as follows:-

$GLOBALS['PERMALINKS']['autopopulate_skipWords']  = array('a','an','and','as','at','before','but','by','from','is','into','it','like','of','off','on','onto','per','since','than','the','this','that','to','up','via','with'); // these seo unfriendly words will be removed

Thanks for the support guys

Regards

Andy

By Dave - December 2, 2013

Hi Andy, 

Thanks for reporting back, I'm glad it's working!

 I have also managed to include some free text by creating some extra fields in the database for these.

Cool, curious how you did that.  Did you just create a field called 'for_sale_in' with a default value of 'for sale in'? 

Thanks, cheers!

Dave Edis - Senior Developer
interactivetools.com