Permalinks 1.02 Questions / Help

Hi

I have just purchased Permalimks 1.02 and am getting to grips with it (slowly)

I have a couple of questions which I hope you can help me with:-

1) I have the plugin generating automatic Permalinks in my Detail Viewer Pages using more than one field which is great. I changed line 11 of the permalinks.php file to do this, copy of code below:-

$GLOBALS['PERMALINKS']['autopopulate_fromFields'] = array('property_type town bedrooms 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

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:-

$GLOBALS['PERMALINKS']['autopopulate_fromFields'] = array('property_type IN town WITH bedrooms BEDS REF 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

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

My code at the top of the page is as follows:-

<?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; }
 
// ++++++++++++++
// Get Page URL
// +++++++++++++++
include("../selfURL.php");
$work_url = (selfURL());
// echo $work_url; // Only used for testing BUT $work_url can be placed in code

?>
<?php permalinks_301redirectToPermalink($listingRecords); ?>

The last line in the code above is what I have added to use the redirect, however, this does not appear to work.

It maybe that I have the wrong variable in the code?

The old page does not redirect but displays the same page as the permalink page so in effect I have 2 URL's pointing to the same page which is not good for SEO.

Any help appreciated on both questions.

Thanks

Andy

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

?>

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