Post by DannyMacD » Tue Oct 20, 2009 9:31 pm

hello,

i cant seem to use this feature properly on the pages i create using the design page feature.

i create a link anchor on a text (example: professional) then make another text item on the same page call "professional".

but when i click it, it goes to: http://myurlname.com/#professional

im confused . com

any help please?

Active Member

Posts

Joined
Fri Jun 26, 2009 6:39 am

Post by readyman » Wed Oct 21, 2009 9:50 pm

You mean you created a link like so...
<a href="#professional">Professional Information</a>
and created the anchor...
<a name="professional"></a>

And it doesn't work?

http://www.alreadymade.com
Follow me on twitter.com/alreadymade


User avatar
Global Moderator

Posts

Joined
Wed May 20, 2009 5:16 am
Location - Sydney

Post by DannyMacD » Wed Oct 21, 2009 11:08 pm

so my coding kinda looks like:

this is the link button.

Code: Select all

<h3><a href="#consumer">For Consumers</a></h3>
then half way down the page i want it to jump to the coding of:

Code: Select all

<p class="intro"><a name="consumer">Consumer</a></p>
is that right? because when i click on it i get: http://myurlname.com/#consumer

Active Member

Posts

Joined
Fri Jun 26, 2009 6:39 am

Post by Qphoria » Wed Oct 21, 2009 11:11 pm

Try this:

Code: Select all

<h3><a href="<?php echo $_SERVER['PHP_SELF'];?>#consumer">For Consumers</a></h3>
You were trying to use a relative anchor.. but since the page load is relative to the root path, I don't think it will work that way. Not sure.. anchors are so 1999 :P

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by DannyMacD » Thu Oct 22, 2009 2:50 am

cheers Q,

but when i tried that as you said i get this as the URL:

http://mydomainname.com/%3C?php%20echo%20$_SERVER['PHP_SELF'];?%3E#consumer



Not Found

The requested URL /< was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Apache/1.3.41 Server at myurlname.com Port 80


:(

Active Member

Posts

Joined
Fri Jun 26, 2009 6:39 am

Post by Qphoria » Thu Oct 22, 2009 3:31 am

DannyMacD wrote:cheers Q,

but when i tried that as you said i get this as the URL:

http://mydomainname.com/%3C?php%20echo%20$_SERVER['PHP_SELF'];?%3E#consumer
eh? why is it urlencoding... ill try it in a bit

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by keclap » Wed Sep 15, 2010 8:13 pm

I believe I've managed to solve this problem. Posting it here in case someone will need it someday :)

Link should be created this way:

Code: Select all

<a href="<?php echo $_SERVER["REQUEST_URI"]; ?>#anchor">link</a>
Of course do not forget to set anchor somewhere in document:

Code: Select all

<a name="anchor">Jump here</a>

Newbie

Posts

Joined
Tue Jul 13, 2010 9:54 pm

Post by Kleo » Sun Oct 03, 2010 12:21 am

I try to use Your solution. It don´t work by me.
I see: "Site not fund".
CKeditor replace the code...

Newbie

Posts

Joined
Wed Nov 18, 2009 4:20 pm

Post by promofire » Tue Feb 08, 2011 3:56 am

Put this in your header template:

Code: Select all

<script type="text/javascript">
jQuery(document).ready(function() {
    jQuery("a[ href ^= '#' ]").each(function() {
        var href = window.location + jQuery(this).attr('href').replace('/#.*/i','');
        jQuery(this).attr('href',href);
    });
});
</script>

Active Member

Posts

Joined
Thu Jan 27, 2011 2:00 am

Post by Lamiaa » Mon Apr 04, 2011 11:58 pm

thaaaaaaaaaaaanx promofire
I have the anchor problem with my website and ur code is v helpful .. It works with me
i wrote the code in the header of the source of every info page
I really appreciate your help
thanx again

a little modification on 11th may . i can understand more now the web developers & designers terms :D :D
I put the code in header template before head end. I think this is what u meant about "your header" to avoid putting the code every time I create an info page.
Last edited by Lamiaa on Wed May 11, 2011 3:02 pm, edited 1 time in total.

Newbie

Posts

Joined
Sat Apr 02, 2011 11:53 am

Post by Sidecutter » Mon May 09, 2011 5:54 am

Promofire, your fix worked perfectly for me, thanks!

Active Member

Posts

Joined
Tue Jan 18, 2011 6:58 am

Post by wackyracer8 » Fri May 13, 2011 1:21 am

I tried this method and it doesn't seem to work for me.

I added the above code to the header and used the following within the html editor of an information page...

Code: Select all

<a href="<?php echo $_SERVER["REQUEST_URI"]; ?>#anchor">link</a>
<a name="anchor">Jump here</a>
The link is displayed as "#anchor">link" and when clicked it brings up "the page you have requested cannot be found"

The URL its directing to is

Code: Select all

domain.com/<?php echo $_SERVER[
What am i doing wrong?

Active Member

Posts

Joined
Fri May 13, 2011 1:15 am

Post by Sidecutter » Fri May 13, 2011 10:02 am

Try it like this, I think where you place the code matters.

In catalog/view/theme/YOUR TEMPLATE/common/header.tpl, look for this section (which should start somewhere near line 44, your line may vary slightly due to any mod differences):

Code: Select all

<script type="text/javascript">
  $(document).ready(function() {    
    <?php if($fancy_default) { ?>
    $("a[rel=fancy_group]").fancybox();
    <?php } else { ?>
    $("a[rel=fancy_group]").fancybox({
	'transitionIn'		: '<?php echo $fancy_transition_in; ?>',
	'transitionOut'		: '<?php echo $fancy_transition_out; ?>',
	<?php if ($fancy_overlay_show) { ?>
	  'overlayShow'		: true,
	<?php } else { ?>
	  'overlayShow'		: false,
	<?php } ?>
	'overlayColor'		: '<?php echo $fancy_overlay_color; ?>',
	'overlayOpacity'	: <?php echo $fancy_overlay_opacity; ?>,
	<?php if ($fancy_autoscale) { ?>
	  'autoScale'		: true,
	<?php } else { ?>
	  'autoScale'		: false,
	<?php } ?>
	'padding'		: <?php echo $fancy_padding; ?>,
	'margin'		: <?php echo $fancy_margin; ?>,
	<?php if ($fancy_cyclic) { ?>
	  'cyclic'		: true,
	<?php } else { ?>
	  'cyclic'		: false,
	<?php } ?>
	'speedIn'		: <?php echo $fancy_speedin; ?>,
	'speedOut'		: <?php echo $fancy_speedout; ?>,
	'changeSpeed'		: <?php echo $fancy_changespeed; ?>,
	'changeFade'		: '<?php echo $fancy_changefade; ?>',
	<?php if ($fancy_show_closebutton) { ?>
	  'showCloseButton'	: true,
	<?php } else { ?>
	  'showCloseButton'	: false,
	<?php } ?>
	<?php if ($fancy_show_navarrows) { ?>
	  'showNavArrows'	: true,
	<?php } else { ?>
	  'showNavArrows'	: false,
	<?php } ?>
	<?php if ($fancy_enable_escapebutton) { ?>
	  'enableEscapeButton'	: true,
	<?php } else { ?>
	  'enableEscapeButton'	: false,
	<?php } ?>
	<?php if ($fancy_title_show) { ?>
	  'titleShow'		: true,
	<?php } else { ?>
	  'titleShow'		: false,
	<?php } ?>
	'titlePosition' 	: '<?php echo $fancy_title_position; ?>',
	'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
	return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
	}
    });
    <?php } ?>    
  });
</script>
AFTER that, immediately after the closing tag for the script (last line above), put the code from above (comments added here for reference):

Code: Select all

<!--START Anchor Redirect-->
<script type="text/javascript">
jQuery(document).ready(function() {
    jQuery("a[ href ^= '#' ]").each(function() {
        var href = window.location + jQuery(this).attr('href').replace('/#.*/i','');
        jQuery(this).attr('href',href);
    });
});
</script>
<!--END Anchor Redirect-->
The next thing, immediately after what you just added, should then be the opening tag of another script.

Active Member

Posts

Joined
Tue Jan 18, 2011 6:58 am

Post by marioj » Thu Jul 14, 2011 4:07 pm

The jQuery piece of code in the header is nice, but know that it may break the DIV tabs functionality. For example, the Description and Reviews tabs on the product page, which look like this:

Code: Select all

<a href="#tab-description"><?php echo $tab_description; ?></a>
<a href="#tab-review"><?php echo $tab_review; ?></a>

Newbie

Posts

Joined
Wed Jul 15, 2009 5:35 am

Post by will_c » Sun Jul 31, 2011 2:34 am

Hello all - just in case anyone else is still struggling with this - I think I've figured it out!

All you need to do is create the anchor as normal for the part of the page you wish to reference and then choose link to URL when you are creating the hyperlink to the anchor, and not link to Anchor.

When you type the URL in just add #anchorname at the end and it seems to work.

Hope this helps someone else.

I'm using vs 1.5.1.

Newbie

Posts

Joined
Sun Jul 31, 2011 2:29 am

Post by Sidecutter » Sun Jul 31, 2011 6:24 am

marioj wrote:The jQuery piece of code in the header is nice, but know that it may break the DIV tabs functionality. For example, the Description and Reviews tabs on the product page, which look like this:

Code: Select all

<a href="#tab-description"><?php echo $tab_description; ?></a>
<a href="#tab-review"><?php echo $tab_review; ?></a>
No, if you're doing it as it should be, it won't affect these at all. I have it in place and these tabs work exactly as they were designed.

Active Member

Posts

Joined
Tue Jan 18, 2011 6:58 am

Post by will_c » Sun Jul 31, 2011 5:41 pm

@Sidecutter - is your system better for SEO reasons than just adding the full URL and #anchorname to a URL Hyperlink? If so and you are sure that it works perhaps I should be doing your method instead! Any thoughts? The system I have been using does seem to work well but I'd like to know if its stuffing anything else up!

Will

Newbie

Posts

Joined
Sun Jul 31, 2011 2:29 am

Post by Sidecutter » Sun Jul 31, 2011 9:12 pm

will_c wrote:@Sidecutter - is your system better for SEO reasons than just adding the full URL and #anchorname to a URL Hyperlink? If so and you are sure that it works perhaps I should be doing your method instead! Any thoughts? The system I have been using does seem to work well but I'd like to know if its stuffing anything else up!

Will
To be fair, it's not my system, it's all Promofire's. I just tried to pass on what I did to make it work properly so it would be easier for others to do. :) Granted, the info I gave is good for 1.4.9.3 to 1.4.9.6 based on my personal testing of those versions, I don't have 1.5 going even as a test right now so the use of the code there may vary wildly, or the code itself might need to be different.

I don't think either method would make any difference in terms of SEO. Since for me it only really comes into play on the FAQ, it's not anything I'd be worried about optimizing for anyway. Both ways lead to the same data when the links are followed since the site automatically fills in the rest of the URL - hover over a clean anchor versus your method, and you'll see they point to the exact same address. The only difference is it would seem to be more of a pain in the arse to redo it or alter it using hard-coded links that included the full URL.

Active Member

Posts

Joined
Tue Jan 18, 2011 6:58 am

Post by will_c » Tue Aug 02, 2011 8:44 am

right - gonna try the jquery! Nice 1.

Newbie

Posts

Joined
Sun Jul 31, 2011 2:29 am

Post by labeshops » Fri Dec 09, 2011 3:11 am

I've been trying to make this work with 1.5.1.3 so that when someone clicks the "read a review" and "write review" links, it jumps to the review tab. Cannot figure it out though - with the javascript added above, my page jumps to the reivew links when the page is loaded.

What do I need to change for it to work?

Running Opencart v3.0.3.2 with multi-stores and the default template from https://www.labeshops.com which has links to all my stores.


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA
Who is online

Users browsing this forum: No registered users and 145 guests