As a Drupal newbie, I am curious about the pros and cons of making changes to the "common.inc" file.

Several developers I have worked with have been hesitant to make changes to the Drupal Core (please correct me if i have made a poor assumption that "common.inc" is a Core file).

Specifically, I am curious about editing the url parameter to create absolute urls (~line 1421) - what, if anything, is the downside of changing this from FALSE to TRUE so that all urls are rendered as absolute.

I know that SEO people are divided about whether absolute or relative urls are more effective for search engine ranking, but I am interested in it strictly from a Drupal standpoint.

Are there potentially issues that could arise from using the absolute urls?
Is there a risk that it would be incompatible with certain modules or themes?
Why is the default for this attribute FALSE?

A bit of context for those who are iterested: it is advantageous to me if a client of mine who is using Drupal will make this change because it is the easiest way to facilitate integration of a Drupal website with our industry specific database software.

I appreciate any feedback.

Thanks,

Comments

nevets’s picture

The "problem" with changing any core file is you need to reapply the changes when upgrade Drupal

bojanz’s picture

Don't do it.
Nothing good ever comes out of hacking Drupal core for things like this.

A hacked Drupal core can steal your car, empty your fridge, and/or eat your cat.

Seriously, don't do it.

cog.rusty’s picture

I think the main reason people hesitate to hack core files is that they want to be able to maintain and evolve only their own code and not also Drupal.

Especially in view of the fact that Drupal is extremely flexible (hooks), without hacking anything.

dman’s picture

For your actual question, use custom_url_rewrite
like this

sam.couture’s picture

Thanks for addressing the underlying question...

And yes, while I certainly am driving at finding a way to accomplish the goal of replacing the relative links with absolute links, I am sincerely interested in knowing why one shouldn't just use whatever means necessary when it comes to Drupal - basically I want to have an intelligent conversation with my clients about why they would or wouldn't make changes to the core.

At the time of the original post I thought I had found a working solution and that the only issue was whether or not to use it (i.e. should a person edit the core? specifically the url portion).

I have since discovered that even editing common.inc does not resolve the issue when using some templates (more details below). As such the "underlying question" is now remains outstanding and perhaps this thread should be moved to a different forum as it is no longer a general question about Drupal, but is a specific question about functionality.

With that said---
If you are willing to put a few more minutes into thinking about the underlying question with me, I should note that one of my clients had actually posted just previous to the comment to which you directed me in your post - Adrienne Duncan working with the Dunwoody Chamber of Commerce. (The examples are not functional at present because they changed directions and are presently using iframes to pull in the database content - view this link to see her example functioning as she indicates)

She mentions that an engineer from the third party they've hired out (that's me) has gotten this integration working with Joomla and even Wordpress websites; it is true that both Joomla and Wordpress sites work quite smoothly with our product with minimal modification - so I was expecting to find a similar "easy" solution with Drupal since it appears to be a more flexible and robust system than either of the other programs mentioned above.

More info about the underlying question:
What I need to accomplish is a rewrite of all links in the page (including links to .js and .css files) so that the page will display and function properly when our server caches a page from the Drupal site and then uses it as a template which "wraps around" content being delivered from our server.

I believe that it could be accomplished by adding an if..else statement to the template, but I was hoping to find a way to do it within Drupal so that future integrations could be accomplished in a uniform way without the developer.

My findings so far:
*When using the Garland template the following 2 options accomplish the goal (I mean to say that either option works independent of the other):
1. changing the url attribute in common.inc to absolute=true (line 1423)
2. setting the base path to the root URL in settings.php (lines 107-126)

*However, when using the Acquia Marina template (which this client is using) neither of the options above worked. This leads me to think that it is a theme based issue, but find it odd that a theme would override "core" functionality -does this sound like a theme based issue to you? And if so, can you point me in the right direction for learning about editing themes?

Also note that adding the custom_url_rewrite lines to settings.php did not do the trick with either template (the documentation on this item did not seem to indicate that anything other than adding those lines was required however I also tried it like the person who posted last on the thread to which you linked indicated)

FYI - here is our documentation about integrating our database modules with a website if it would be helpful.
http://kb.chambermaster.com/?page_id=2

Lastly, for those who are adamant about not changing the core -
Altering all of the links throughout the site to absolute links seems like a rather innocuous change - would anyone care to share anything more in depth about why it is not recommended to change this specific part of Drupal? (other than my car, fridge, and cat being consumed by my hack - which would undoubtedly be regrettable...)

Thanks again,

dman’s picture

Altering all of the links throughout the site to absolute links seems like a rather innocuous change
I haven't seen anyone argue against what you want to do. It's all about how.
Wanting to pick up a penny is a reasonable desire. But stepping in front of a truck to do so is unwise.

Your actual question was "Why not change core?" and you got responses to that.
If your question really is actually "How to globally change links?" then you are not getting anyone being adamant about anything.

Now you've had enough finger-wagging, it's your choice to go ahead however you feel. I don't think it will hurt what you want to do right now. It's in a years time that the blood will begin. So strap yourself into a VCS and do what you must.

I can't really say why there's such little support for absolute URLs, except that many folk probably use dev sites, backups and test servers - and find that hard URLs can mess with that. I'm sure there are other fixes out there for it. The SEO wallys keep trying to do it.

I had a look at Acquia theme, but don't see any special reason why it would be changing behavior as you describe. I thought there was a simple fix, just can't see it ...

sam.couture’s picture

Well said, perhaps a better way to have posed my question would have been "Is there a better way to solve this specific issue than by editing core?" and finger wagging was certainly in order as there were multiple layers of the question and the title certainly did not hint at the underlying question.

Until WorldFallz explained it in more detail in her most recent post, the meaning/significance of the previous warnings not to alter core files were lost on me. At this point I am convinced that altering core, or asking my clients to do so, is absolutely not the best option (mostly b/c I would not want to be responsible for causing a mess when they want/need to upgrade.)

Thanks for again for taking the time to look at this and respond

sidenote: I read almost the entirety of http://www.catb.org/~esr/faqs/smart-questions.html#before and found it good natured, insightful, and helpful - I must confess that this is not only my first post in a Drupal forum, but also the first post that I recall making in any forum...

sdocpub2’s picture

Hiya Sam! Didn't realize that you were nosing around for a solution to the CM integration as well. :-)

Yes, I defaulted to IFRAMEs for CM content. Not a pretty solution but it worked.

I tried to edit common.inc for hours in an attempt to convert all URLs from relative to absolute and got bupkiss.

Here's the thing about telling clients to hack core: not everyone knows what they're doing or how to undo it in a pinch. Further, even if you have IT pros on site (like me and my colleagues in Dunwoody) we have to be prepared for the possibility that we would not be able to assist at some time in the future. What would happen if they lay folks were handling the site on their own? They'd probably have to start over with something easier to manage or pay a fortune to bring in someone else.

We haven't tried other templates yet (although we're redoing our layout around January-ish) and I'll be pleasantly suprised if that makes integration easier.

If someone comes up with a module or other solution for this type of situation, I'll be glad to try it out, as long as it doesn't slow the site down to that of a glacier.

Adrienne Duncan
SDOC Publishing

sam.couture’s picture

One of our new guys was a web developer who used Drupal prior to working for ChamberMaster and he has documented an integration method that has worked for several clients - http://kb.chambermaster.com/drupal

WorldFallz’s picture

would anyone care to share anything more in depth about why it is not recommended to change this specific part of Drupal

The magnitude of the change or the specific part of drupal being changed has nothing to do with it. Whether you change 1 line of code or 1000, by doing so you create a fork that must now be maintained separately. It never seems like much when you do it-- especially when you can hack what you want in 5 mins as opposed to spending 30 minutes learning the proper way to do something. However, all those little hacks add up and pretty soon upgrading drupal (which can and does change significantly between major releases) turns into a quagmire as you try and figure out which of your hacks has been affected by changes in the new version of core.

No thanks-- I'd rather spend a little more time up front learning the proper drupal way than a lot of time later on sorting through core hacks prior to doing an upgrade. obviously, it's your site and you can do whatever you want but the subject of your post was quite specific and that's the replies you received.

sam.couture’s picture

I appreciate the detail in this response. As someone who is not entirely familiar with Drupal, it is great to hear the context in relation to updates and the headache that it would create down the road - I am sold that editing core is not a good option.

In this case I had already invested far more than 30 minutes in finding any solution for this and one of my clients had previously invested many hours in trying to get this figured out, so I don't think it is quite as cut and dry as 5 minutes to make the core change vs. 30 minutes to learn the Drupal way, but point taken...

cog.rusty made some suggestions that I think have me headed in a workable direction for this somewhat unique scenario.

Thanks again,

WorldFallz’s picture

glad to help sort it out ;-)

cog.rusty’s picture

It looks like the custom_url_rewrite_outbound() solution applies only to virtual drupal paths, not to real files (not sure how consistently). For example
- it works when the page template prints $front_page or the menu links.
- but not when it prints $logo, which is a real image link.
- and of course not with manual links in the content or in user blocks.

http://api.drupal.org/api/function/template_preprocess_page/6

 $variables['front_page']        = url();
 ...
 $variables['logo']              = theme_get_setting('logo');

As far as I can tell, unlike internal paths which can be controlled by url(), tracing back file or theme paths controlled by drupal_get_path() and such, we end up to base_path(), which there is no way to give you an absolute URLs directly. So, the way things are, maybe the only way is to override those template preprocessor variables in a template.php file in the theme, to stick $base_url in front of them.

Links in the content are another matter. A filter module could scan the content for anchor tags.

sam.couture’s picture

Thanks for the insight into how custom_url_rewrite_outbound() works - it sounds like I would need to use this function (for the menu links and front page link) in combination with adding $base_url to the preprocessor variables in the template.php file. I will try this and post whether this succeeded or not.

WorldFallz’s picture

simple-- there are no 'pros'.