0

I have a problem with a CEWP not rendering because of the link entered. It is a custom WP, but what was customized is just the CSS, so I'm pretty sure that the CSS isn't causing the issue. I have the WP in a particular site collection. For some reason, absolute links cause the WP to not render properly, it just shows the text of the WP file, so I'm trying to use the relative URL instead. In general, relative links work, but the link I need (which points to a page in a subsite) causes the WP to not render properly like it does with absolute URLs.

The current URL where the CEWP is placed is: /sites/Blah/Pages/Home.aspx

While the URL I'm trying to point to is: /sites/Blah/Subsite/default.aspx

The link I'm trying to add in the CEWP is: ../Subsite/default.aspx

I need ../ since it has to go up a level, then append the link or else the CEWP link resolves to /sites/Blah/Pages/Subsite/default.aspx, which doesn't exist and leads to a Page Not Found.

I've read multiple posts talking about this relative URL 'problem', but I haven't found one that had a solution involving linking to a subsite and not just some asset file. I'm pretty sure ../ is causing the problem, but I don't understand why.

0

I think you can not use relative links with .. (parentside) references

It is probably programmed that way because a WebPart can be saved as Template
and placed on another site that link will most likely break.
Not to confuse users, MS just disabled all relevative links

If you want dynamic loading of a script then do that with JavaScript inside WebPart code

Pseudocode:

<SCRIPT>
var myscr=document.createElement('SCRIPT');
myscr.src="../myrellink/myscript.js";
myscr.onload=function(){
  console.log('The Blue pill or the Red pill?');
}
document.head.appendChild( myscr );
</SCRIPT>
  • This isn't answer my solution, but this is helpful information. I didn't exactly fix the problem, but I used the Ribbon to edit the link instead of through the sidebar web part editor. For whatever reason, even if the link works, as soon as it was saved by the editor, none of the changes would be applied. This was a custom web part (not made by me) so I'm thinking there's something wrong with how it was created that resulted in my original issue. Thank you! P.S. The link was just to a regular SP webpage, not to a file or anything. – LaLaLottie May 18 '17 at 20:06
0

Make sure your CSS is wrapped in a <style></style> tag

  • It is. It's not the CSS causing this I'm sure. – LaLaLottie May 17 '17 at 20:09
  • Quote: "For some reason, absolute links cause the WP to not render properly, it just shows the text of the WP file".... If you can see the contents of the linked file, your problem isn't the link. Do you mind sharing a snipped of the styles? – Oxossi May 17 '17 at 20:22
  • Thank you for your answer/comment. It's not the CSS; this was a custom web part not made by me, and I suspect that there was something wrong with the WP properties, etc. to cause issues with the WP editor. So not the CSS, but probably the WP markup messing things up. – LaLaLottie May 18 '17 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.