This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Overwrite the url send to the "url" database column?
#1

Is it possible to override the URL that's being sent off to the database entry of a comment? Since my site hosts a comic, the most recent issue is always displayed on the front page. So this is also where almost all people comment. The problem is that it all gets written in the DB as "https://leavingthecradle.com", instead of, say "https://leavingthecradle.com/comic/148" (the link to the actual page from any other part of the site), and the links in the emails and the admin panel that are supposed to lead to that comment lead to the front page instead of the actual comic's page. Naturally, these links cease to lead to the comment as soon as the new comic is released.

If it would be possible to define the url value right in the php integration snippet, the one where it defines $cmtx_identifier and $cmtx_reference, it would be extra nice.
Reply
#2

Which integration method are you using?

Have you completed the interview?
Reply
#3

I'm using the PHP code one.
Reply
#4

Ah yes, just noticed you already said that.

In the integration code add this:
PHP Code:
<?php 
$cmtx_link
= 'http://your-url-here.com';


In /frontend/index.php, after this:
PHP Code:
<?php 
if (isset($cmtx_reference)) {
    define('CMTX_REFERENCE', $cmtx_reference);
}

Add this:
PHP Code:
<?php 
if (isset($cmtx_link)) {
    define('CMTX_LINK', $cmtx_link);
}

In /system/library/page.php, change this:
PHP Code:
<?php 
if (defined('CMTX_PAGE_URL')) { // only set for iFrame
    $this->page_url = $this->security->encode(CMTX_PAGE_URL);
} else {
    $this->page_url = $this->url->getPageUrl();
}

To this:
PHP Code:
<?php 
if (defined('CMTX_PAGE_URL')) { // only set for iFrame
    $this->page_url = $this->security->encode(CMTX_PAGE_URL);
} else if (
defined('CMTX_LINK')) {
    $this->page_url = $this->security->encode(CMTX_LINK);
} else {
    $this->page_url = $this->url->getPageUrl();
}

Have you completed the interview?
Reply
#5

Thanks!
Reply
#6

Ok, I don't know what is going on here, but if I paste your code directly where you told me - it breaks the site. Page won't load. But if I paste it into notepad first, delete ALL the whitespaces, and then copy it again out of there - it doesn't break the site anymore. I almost pulled my hair out trying to figure out why even the addition of a single desperate line
Code:
$pleasefortheloveofgodWORK = 0;
would be breaking the page.


Edit:
Ok, after testing it out, this now writes "https://leavingthecradle.com/comic/147" as "https://leavingthecradle.com/147", despite I SPECIFICALLY write "https://leavingthecradle.com/comic/147" in $cmtx_link
Reply
#7

Can't edit previous mesage, so sorry for spam. It seems like it specifically disliked the "https" part. Once I've changed it to "http" - it now correctly adds to the database without dropping the \comic\ part of the url. Weird...
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Jim
29-Mar-2012, 12:17 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)