|
Integrating with dynamic links (Outdated)
|
|
10-Aug-2010, 02:08 AM
Post: #1
|
|||
|
|||
|
Integrating with dynamic links (Outdated)
Commentics, as you all know, is a great comment script with many features. With the release of version 1.1, extra functionality has been added. On of the key features of 1.1, in my opinion, is the ability to integrate Commentics in dynamic links, such as "www.example.com/comment_page.php?variable=value". This tutorial explains how to integrate Commentics efficiently with such links.
There are several things to determine before you start, though. Some links are meant to determine which layout the site will have: ("comment_page.php?layout=article1"), others are just to determine some value: ("comment_page.php?time=800"). Sometimes, you want to put those together: ("comment_page.php?layout=article1&time=800"). Nevertheless, exactly one variable determines the layout. In some cases, you want two or more variables for the layout: ("comment_page?layout=articlepart1&sublayout=articlepart2") and ("comment_page?layout=articlepart2&sublayout=articlepart5"). First, I'll explain the first case. Lets start by going to the dynamic page that you want to add a comment section to: ("www.example.com/comment_page.php?layout=article1"). Open up the Commentics back-end, and go to "manage->pages". Copy the url, and paste it into the "new page URL" box. Add a reference, and add the page. For now, let's leave it at that. Open the source of the page that needs the comments section, and go to the include lines: PHP Code: <?php PHP Code: $page_id = $_GET['layout']; Go back to the admin panel, and edit the page which you created earlier. In the "Custom ID" field, input the name of 'value' where 'value' is the value of the variable: ("comment_page.php?layout=article1") will make 'value' = article1; This requires that you know the variable name of the page you need. Save the changes, and you're done! If you have a lot of pages already, this method will be slow and tedious, though. For this reason, I've created a piece of code which will make the process a lot faster and easier. This code should be put in "comments/includes/commentics.php" after the section called "ADMIN DETECTION". PHP Code: /**************************************************ADMIN ADDITION**************************************************/For the second case, it is very prefferable to create another variable to determine the comments section id. If that's not possible, follow everything above, but try setting the custom id to be "variable1"+"variable2", so: (comment_[age.php?layout=article2&sublayout=article5) would have a custom id of "article1article5", and the include script would be PHP Code: $page_id = $_GET['layout']+$_GET['sublayout']; When you are done with the code that you put into "commentics.php", it is advised to delete it, as it will still be on the page, even after it has been successfully added. It is included as a simplification of the process, but it is not styled, or fully developed. It is possible that I will include the above code in an add-on. No guarantees, but I might do it. If you have any questions, comments, or feel that I've missed something, I'll be glad to help. If I decide to change something, I doubt that it'll be possible for *me* to change this post, so make sure you read the rest of the thread for further changes, if any. I'm giving you three guesses... |
|||
|
10-Aug-2010, 06:52 PM
Post: #2
|
|||
|
|||
|
RE: Integrating with dynamic links.
Ah, yes, there is one thing I forgot to mention. If you don't want someone to see an "invalid id" error if they decide to enter something in the url, then add a check against it.
PHP Code: switch($_GET['layout'])Then shove the include script into an if statement: PHP Code: if(defined('VALID_COMMENT_PAGE'))One advantage of this is that you can add an optional else statement to show something else when a comment system isn't supposed to be there. Enjoy! I'm giving you three guesses... |
|||
|
01-Sep-2010, 12:35 AM
Post: #3
|
|||
|
|||
|
RE: Integrating with dynamic links.
I should have added this a while ago.
With the Arbitrary ID add-on, dynamic links are automatically added, so you have to do almost nothing. There are a couple of drawbacks with that add-on, such as a user entering a value into the URL that you didn't anticipate, but that's how all arbitrary IDs work. I've added how to deal with that too. For more information, go to the Arbitrary ID thread under add-ons: http://www.commentics.org/forum/showthread.php?tid=56 I'm giving you three guesses... |
|||
|
07-Oct-2010, 07:58 PM
Post: #4
|
|||
|
|||
|
RE: Integrating with dynamic links.
Is there a way to make this work with two categories?
url.php?restaurant=1 and url2.php?attraction=1 They have seperate ID's but some have the same Custom ID, like "1" in the example above. I know. I'm a pain.
|
|||
|
07-Oct-2010, 08:21 PM
Post: #5
|
|||
|
|||
|
RE: Integrating with dynamic links.
I'm not quite sure what you mean, but you can try:
PHP Code: if(isset($_GET['restaurant']) && $_GET['restaurant'] != null && $_GET['restaurant'] != "")What this does is check if the restaurant variable exists, and isn't empty. If so, it sets the page id to be the value of that variable. Then, it does the same for the attraction variable. This means that if both are set, then attractions will override restaurants. This can be fixed by adding: PHP Code: if(isset($_GET['restaurant']) && $_GET['restaurant'] != null && $_GET['restaurant'] != "" && isset($_GET['attraction']) && $_GET['attraction'] != null && $_GET['attraction'] != "")Hope that this isn't too confusing, and that it helped too... These examples assume that it's the same page, but with different variables: an_url.php?restaurants=1 an_url.php?attractions=1 an_url.php?restaurants=1&attractions=1 with all the base URLs being the same. Oh, you edited the post above. Let me fix mine. I'm giving you three guesses... |
|||
|
07-Oct-2010, 08:28 PM
Post: #6
|
|||
|
|||
|
RE: Integrating with dynamic links.
Hmmm... thanks for that.
What I have is two different urls: attractions_and_entertainment_in_provo.php?attraction=ID list_of_restaurants_in_provo.php?restaurant=ID So that is close to what I would need. What is happening right now is that the comment page with customID of 2 and ID 4 is being used for both urls, when I want another comment page with customID of 2 and ID 5 being used on the other. Does that make sense? |
|||
|
07-Oct-2010, 08:28 PM
Post: #7
|
|||
|
|||
|
RE: Integrating with dynamic links.
If you know the name of the variable, you can do:
PHP Code: $page_id = "restaraunts".$_GET['restaurants']; That should work. You see, this tutorial wasn't really meant for variables with a number value. I forgot to take that into account ![]() BTW, this could be the reason for the incorrect referrer bans you were having earlier. I'm giving you three guesses... |
|||
|
07-Oct-2010, 08:50 PM
Post: #8
|
|||
|
|||
|
RE: Integrating with dynamic links.
It doesn't seem to detect it now. Is it possible to use the url path + customID to locate the correct comment page?
(http://www.provohappening.com/list_of_re...urant=205) thanks for all your help btw |
|||
|
07-Oct-2010, 09:01 PM
Post: #9
|
|||
|
|||
|
RE: Integrating with dynamic links.
I think that you forgot to add the id in the backend.
My add-on can really help. It adds the page automatically, and it has a certain variable that you can use to do just that. You can use PHP Code: $page_id = "http://www.yoursite.com".$_SERVER['REQUEST_URI']; If you decide to use the add-on, then change PHP Code: $arbitrary_id_reference = '';//Your value/variable here PHP Code: $arbitrary_id_reference = $current_page_url;//Your value/variable here I'm giving you three guesses... |
|||
|
07-Oct-2010, 09:18 PM
Post: #10
|
|||
|
|||
|
RE: Integrating with dynamic links.
I guess I must be missing something.
PHP Code: $page_id = "http://www.yoursite.com".$_SERVER['REQUEST_URI']; has been added and works fine, but it doesn't pull up the connected comment page with that url. I've added the arbritary-id to commentics and changed the insert script to fit it, and the reference var without any progress. Maybe this will help. |
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)

Search
Member List
Calendar
Help



