Hide a link with its text

Hide a link with its text

by omid hamedi -
Number of replies: 7

Hello. How to hide a link with its text. This text has a common class with other texts.

For example:

<a href=”http://mysite.com” >one text</a>

From the Additional HTML section, I put the following code in all three sections 

<a id=”hided" href=”http://mysite.com” >one text</a>


and placed its id in the custom css section in the classic theme and boost theme. This code:

#hided { display: none !important;}

But no change was made and the text and link were not hidden.


Average of ratings: -
In reply to omid hamedi

Re: Hide a link with its text

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers
I’m confused! You added a link to the Additional HTML section and now you want to hide it using css?? If you don’t want people to see the link, why can’t you just delete it rather than hiding it?

Anyway, the css is wrong. The hash should be at the beginning and the semi-colon at the end. And you shouldn’t need !important for display: none;

Try
#hided {display: none;}

In reply to Jon Bolton

در پاسخ به: Re: Hide a link with its text

by omid hamedi -
Thankful
I actually tried to hide the "front page settings" option for the manager role. But there was no way because by disabling moodle/course: update, although I reached the goal, but the manager role can no longer create course.
That's why I decided to hide the "front page settings" option and its title (Its title is "front page") with css code. But these two texts have a common class with all the texts that are in the site administration, and by hiding one of them with that class, the other texts are also hidden.  I created a dedicated ID for the front page settings option:
<a id=”hided" href=”http://mysite.com” >front page settings</a>
and
<a id=”hide" href=”http://mysite.com” >front page</a>

And then with CSS code I tried to hide the dedicated ID to hide the front page settings.
#hide {display: none;}
#hided {display: none;}
I created the #hide and #hided ID myself
But I did not succeed

And there was no problem that the front page settings option was hidden by the CSS code for all roles because when necessary I can temporarily display it and hide it again.

I can not use the #hided {display: none;} code, because the #hided ID for the "front page settings" and "front page" must be created first. Is that right?
In reply to omid hamedi

Re: در پاسخ به: Re: Hide a link with its text

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers

You can’t achieve what you want to do in that way.

Did you know you can override permissions in all contexts, including the front page?

Go to yourmoodle/admin/roles/permissions.php?contextid=2, which should be the permission setting for the front page. Choose “manager” from the drop down list to override, filter on “update” and prohibit the capability to update course settings, and that MIGHT solve your problem. You’re doing the same as when you changed the permissions to disable course update, but only in the context of the front page. Anywhere else, the permissions will revert to the default settings.

In reply to Jon Bolton

در پاسخ به: Re: در پاسخ به: Re: Hide a link with its text

by omid hamedi -
excellent. Thank you very much jon
I will test this method and announce the result here
In reply to Jon Bolton

در پاسخ به: Re: در پاسخ به: Re: Hide a link with its text

by omid hamedi -
it works. Great. Thankful
Can we be absolutely sure that doing this in this way will have no effect on other settings and only the ability to display the front page settings option for the manager role is prohibited?
In reply to omid hamedi

Re: در پاسخ به: Re: در پاسخ به: Re: Hide a link with its text

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers
If you have only overridden the manager role in the front page context, and only then the capability to update courses, then yes, it will only affect the manager’s ability to edit the front page settings. But as with any change, you should test it - check whether the manager role can’t edit the front page but can edit a normal course.
Average of ratings: Useful (1)
In reply to Jon Bolton

در پاسخ به: Re: در پاسخ به: Re: در پاسخ به: Re: Hide a link with its text

by omid hamedi -
Thank you jon
merci