This module provides a site base URL token in Views. The main purpose of this module is to create a link with absolute path through "Global:Custom text" option.

Usage:

  • Select field formatter in view, and add "Global: Base url"
  • Select "Exclude from display" option.
  • Create custom link by adding a "Global:Custom text"
  • Create link like this: <a href="[base_url]/home">My home page</a>

Why use this module:
You can also create custom links though Drupal l() function, in this case you have to use Views PHP module. The code is stored in database, hence it will not be cached. PHP execution through eval() is slow. This module eliminates this problem.

Alternatives:
Only module I found closest to this is Views BaseURL, its in sandbox and that too it was last modified years ago, means its not maintained.

Sandbox project:
https://www.drupal.org/sandbox/subhojit777/2295145

Git repository:
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/subhojit777/2295145.git views_base_url

More features yet to come:

  • Will add an option to add the base URL as link itself (done)
  • Add fragment and query options (done)
  • Use replacement patterns (done)
  • Option to show the link as image

Pareview.sh:
http://pareview.sh/pareview/httpgitdrupalorgsandboxsubhojit7772295145git

Projects reviewed:
- https://www.drupal.org/node/2237631#comment-8928031
- https://www.drupal.org/node/2215325#comment-8928355
- https://www.drupal.org/node/2290215#comment-8928691

Comments

subhojit777’s picture

Issue summary: View changes
subhojit777’s picture

Issue summary: View changes
PA robot’s picture

Multiple Applications
It appears that there have been multiple project applications opened under your username:

Project 1: https://www.drupal.org/node/2295233

Project 2: https://www.drupal.org/node/1844398

As successful completion of the project application process results in the applicant being granted the 'Create Full Projects' permission, there is no need to take multiple applications through the process. Once the first application has been successfully approved, then the applicant can promote other projects without review. Because of this, posting multiple applications is not necessary, and results in additional workload for reviewers ... which in turn results in longer wait times for everyone in the queue. With this in mind, your secondary applications have been marked as 'closed(duplicate)', with only one application left open (chosen at random).

If you prefer that we proceed through this review process with a different application than the one which was left open, then feel free to close the 'open' application as a duplicate, and re-open one of the project applications which had been closed.

I'm a robot and this is an automated message from Project Applications Scraper.

PA robot’s picture

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

subhojit777’s picture

You will see some issues in pareview.sh, but they cannot be fixed. I am inheriting Views handler functions, changing the case of those functions in module will not work (https://api.drupal.org/api/views/handlers!views_handler_argument.inc/fun...)

subhojit777’s picture

Issue summary: View changes
subhojit777’s picture

Issue summary: View changes
subhojit777’s picture

Issue tags: +PAreview: review bonus
tregismoreira’s picture

In your application:
It's bad to post a "GIT clone command" with your own GIT user. It's better to post a clean command like this: git clone --branch 7.x-1.x http://git.drupal.org/sandbox/subhojit777/2295145.git views_base_url

In your includes/views/views_base_url.views.inc file:
Line 13: It's a recommendation to use single quotes as default, except when your string have apostrophe.

subhojit777’s picture

Issue summary: View changes
subhojit777’s picture

I used double quotes instead of single quotes to make it consistent with next line of code.

function views_base_url_views_data_alter(&$data) {
  $data['views']['base_url'] = array(
    'title' => t("Base url"),
    'help' => t("Site's base url"),
    'field' => array(
      'handler' => 'ViewsBaseUrlHandlerBaseUrl',
    ),
  );
}

Now that you have pointed out in coding standard documentation, I have made the changes.

Thank you.

gbisht’s picture

Status: Needs review » Needs work

@subhojit777 pareview.sh is showing some coding standard issue with code.
http://pareview.sh/pareview/httpgitdrupalorgsandboxsubhojit7772295145git

klausi’s picture

Status: Needs work » Needs review

Looks like those Views method names cannot be changed, please do a real manual review.

EthanT’s picture

1) Functionally: Module installs, and Global base url field is available, and throws no errors when plugged into view.
2) Code is fine, but there really isn't much to critique. PAReview is throwing a couple of false errors, imho (relating to CamelCase in handlers).
3) I don't think there is enough here for this project to qualify the user for sandbox to full project promotion status. There are only a couple of hooks, and a handler.

subhojit777’s picture

Thank you Ethan for the review.

I have always tried to eliminate PHP code from database as far as possible. In case of views there are several modules which allows you to do some custom changes in views without having to write PHP code, like Views Custom Conditions, Views Conditional and then there is Views PHP which allows you to add custom fields in views. Views PHP adds code to database. There are several problems we can face if too much code database code is executed.

This module solves one of the problem, i.e. we can create custom absolute links without using Drupal l() function.

The modules basic use is to provide a token using which we can create custom absolute URLs and show them as view fields. But I have added more features to it so that you can create a proper link (with class, fragment, query, etc.) I am currently working on replacement pattern feature. Will also add feature for displaying the link as image. After this the module will have good scope.

I am considering this project as "a step to eliminate PHP code from database"

subhojit777’s picture

Issue summary: View changes
klausi’s picture

Assigned: Unassigned » heddn
Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus

Review of the 7.x-1.x branch:

  • DrupalPractice has found some issues with your code, but could be false positives.
    FILE: ...review_temp/includes/views/handlers/views_base_url_handler_base_url.inc
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     128 | WARNING | Unused variable $arg.
    --------------------------------------------------------------------------------
    

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.

manual review:

  • $output = t('<p>You must add some ...: HTML tags should be outside of t() where possible.
  • ViewsBaseUrlHandlerBaseUrl::query(): Doc comment is misleading because you are not adding anything to the query. You should comment that you have to override the parent method.

But otherwise looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

Assigning to heddn as he might have time to take a final look at this.

subhojit777’s picture

@klausi thanks for the manual review. I have changed the code as per your suggestions, also there was an error I have missed, fixed that one too.

heddn’s picture

Status: Reviewed & tested by the community » Fixed

I did a manual review of this project as well. The only thing I found was an undefined index issue for the query string. No validation is done on the entered value to verify that the value is strings of text separated by an equals sign. And my text wasn't well formed so error gets returned. I can also see some validation is required on the link class, to format as valid HTML classes. And the target to verify the string is a single word of text not separated by spaces.

Notice: Undefined offset: 1 in ViewsBaseUrlHandlerBaseUrl->render() (line 200 of \pareview/sites/all/modules/views_base_url/includes/views/handlers/views_base_url_handler_base_url.inc).

However, none of these things are blockers... and can easily be fixed prior to a full release.

Thanks for your contribution, subhojit777!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

subhojit777’s picture

Thank you very much Lucas and Klaus for your efforts! This is my first project in Drupal and I hope I will do more contributions to Drupal in future. Thank you again.

PA robot’s picture

Status: Fixed » Closed (duplicate)
Multiple Applications
It appears that there have been multiple project applications opened under your username:

Project 1: https://www.drupal.org/node/2312633

Project 2: https://www.drupal.org/node/2295233

As successful completion of the project application process results in the applicant being granted the 'Create Full Projects' permission, there is no need to take multiple applications through the process. Once the first application has been successfully approved, then the applicant can promote other projects without review. Because of this, posting multiple applications is not necessary, and results in additional workload for reviewers ... which in turn results in longer wait times for everyone in the queue. With this in mind, your secondary applications have been marked as 'closed(duplicate)', with only one application left open (chosen at random).

If you prefer that we proceed through this review process with a different application than the one which was left open, then feel free to close the 'open' application as a duplicate, and re-open one of the project applications which had been closed.

I'm a robot and this is an automated message from Project Applications Scraper.

klausi’s picture

Status: Closed (duplicate) » Fixed

This should stay as fixed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.