Is it possible to have the contents of the iframe show up using the default Drupal search of the website? Mine do not appear to be doing so.

Comments

MarcElbichon’s picture

Status: Active » Closed (won't fix)

Do you mean you want to add in search database content contained in iframe ?

First, to do this, iframe content must be in same domain, because parent page can't access content of iframed page if cross domain.
Next, only first page of iframe can be get by server. Links in page cannot be wrapped.

I think this is a very specific request so i won't fix it, sorry.

Maybe can you do this with use of theme function like this :
In your template.php

function mytemplate_insertFrame_render_url($vars) {
    $url = $url = $vars['value'];
    $content = file_get_contents($url);
    // Add content to search engines
    ...
    return theme_insertFrame_render_url($vars);
}
monuska’s picture

Yes, I want to add the content contained in the iframe to the search database. All files are hosted on the server in different directories, I am linking to them using [[[//.html]]]

I'll try your suggestion with the template.php file.

Thanks for your help.

monuska’s picture

Category: feature » support

... and apparently I have no idea how to do this correctly.

I'm still learning PHP, could you give me an example of the above, using a file /staff/list.html ?

MarcElbichon’s picture

What is your seach engine ?
If this is Drupal default search, you may do that (not tested):

function mytemplate_insertFrame_render_url($vars) {
    $url = $url = $vars['value'];
    $content = file_get_contents(url($url, array("absolute" => TRUE)));
    // Add content to search engines
    search_index(arg(1), 'node', $content);
    search_update_totals();
    return theme_insertFrame_render_url($vars);
}

monuska’s picture

Yes, Drupal is my default search, I will give the above a try.

Thank you so much for all your help, I really appreciate it.

ajm333’s picture

My organization is having the exact same problem. We have users who create their own HTML pages (usually in Word) which are then displayed in the corresponding node using insertFrame. The users are complaining that their content does not appear in the search (also using Drupal for that). I have tried using the above code but cannot get it to work. Unfortunately, I know nothing about coding in PHP -- am I supposed to change any lines or text to get it to work with our site and specific files? Filepath is in the root directory (/WordFiles), filenames vary by user. There are approximately 25 of these. Example of include code is [[[/WordFiles/user1.html]]]

I could really use some help on this!

MarcElbichon’s picture

Have you replaced mytemplate in mytemplate_insertFrame_render_url() function by the name of your template ?
I.e : If your template is garland, function must be garland_insertFrame_render_url().

Don't forget to flush cache

MarcElbichon’s picture

I've commited to dev a new version to add content to search engine.
In input format settings, check "Add to search engine" setting for insertFrame filter

Be careful. If iframed page is modified, Drupal won't detect this, so modification won't be indexed. You must go to edit tab of the node and submit page to reindex page at next cron time.