Hello, my problem is that I have a very long page. When you click on the links at the bottom of the page you have to be able to roll up very far to see the Ajax content.

Can I get it that the Ajax link always jumps to the actual node title or image on top? Similar to anchor links?

Greetings Frank

Translated with Google

CommentFileSizeAuthor
#4 pic.jpg891.09 KBfrank hh-germany

Comments

serjas’s picture

Currently no, but you can achieve this by hacking from line 132 of ajax_links_api.module.

For example ajaxify https://drupal.org/node/2218779#comment, then split the fragment (#) and generate link using fragment

$link = l($element['title'], $element['path'], $options = array(
  'attributes' => array(
    'class' => 'ajax-link',
    'rel' => $element['target'],
    'fragment' => FRAGMENT_YOU_SPLITED
)));
frank hh-germany’s picture

Hi, firstonce Thank you.
Unfortunately this does not work and I have now tried a lot.
Parse error: syntax error, unexpected '<' in / homepages/42/d252324900/htdocs/tecmawi/sites/all/modules/ajax_links_api/ajax_links_api.module on line 132
-------------------------------------------------------------
Parse error: syntax error, unexpected ')' in / homepages/42/d252324900/htdocs/tecmawi/sites/all/modules/ajax_links_api/ajax_links_api.module on line 130

Here is the code I've tried preferred. Beginning line 120; End line 140

}
/**
 * Theme ajax_links_api.
 */
function theme_ajax_links_api_link($element) {
  $link = l($element['title'], $element['path'], $options = array(
    'attributes' => array(
      'class' => 'ajax-link',
      'rel' => $element['target'],
      'fragment' => # (OR #! FOR GOOGLE)
    )));
  return $link;
}
/**
 * Implements hook_preprocess_page().
 */
function ajax_links_api_preprocess_page(&$variables) {
  // This is used to display only $content.
  if (isset($_GET['ajax']) && $_GET['ajax'] == 1) {
    $variables['theme_hook_suggestions'][] = 'page__ajax';
    // To override page--ajax.tpl.php for content types.

-------------------------------------------------------
Would be nice if you it has a solution.
Do I understand correctly that I then have to insert only on the target page an anchor?

The landing page is linked via an image. I use this with the Delta Image Module. > Link to Content.

Can we formulate as follows: :
'rel' => $element['target-top'], or
'rel' => $element['target-image'], or somehow similar?

Greetings Frank

frank hh-germany’s picture

Ok, now I have used the following code.
There are at least no more error messages.

function theme_ajax_links_api_link($element) {
  $link = l($element['title'], $element['path'], $options = array(
    'attributes' => array(
      'class' => 'ajax-link',
      'rel' => $element['target'],
      'fragment' => 'FRAGMENT_YOU_SPLITED'
    )));
  return $link;
}

On the home page, I have placed an anchor.
On the previous page I have a link with #top placed.

Despite Hashlink and anchor but is not bound to the anchorage.

After the array still would have a command here, as show the page title, or go to the beginning of the main content.

Unfortunately, I am familiar with php and co not look good.

Could it work here somehow?

function theme_ajax_links_api_link($element) {
  $link = l($element['title'], $element['path'], $options = array(
    'attributes' => array(
      'class' => 'ajax-link',
      'rel' => $element['target'],
      'rel' => 'image',                             <em>(or any field used)</em>
    )));
  return $link;
}

Greetings Frank
I just still found here. Can I automate this?
onclick="parent.window.scrollTo(0,0);"

and another fund is here. Where should the be placed?
If the first 0 of the distance from the top and the second 0 of the distance from the left?

<script type="text/javascript"><!--
window.onload = function() {
  scrollTo(0,0);
}
// -->
</script>
frank hh-germany’s picture

StatusFileSize
new891.09 KB

Here is a picture of my unfinished Homepage