Problems with ossn_com.php and CSS and active cache

Dominik L Posted in Technical Support 11 months ago

Hey!

I try to load 4 CSS files when a user is not logged in

I tried:

<?php
/**
 * Open Source Social Network
 *
 * @package   Dominik Lieger
 * @author    Dominik Lieger
 * @license   GPL v2 https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * @link https://www.example.com
 */

function login_rearr() {
	
	if (!ossn_isLoggedin()) {	
	
    ossn_extend_view("css/ossn.default", "css/login_rearr");
    ossn_extend_view("css/ossn.default", "css/footer");
    ossn_extend_view("css/ossn.default", "css/loginform");
	    ossn_extend_view("css/ossn.default", "css/signupform");
}
}
ossn_register_callback("ossn", "init", "login_rearr");

and

function login_rearr() {
    $user = ossn_loggedin_user();

    if (!$user) {
        ossn_extend_view("css/ossn.default", "css/login_rearr");
        ossn_extend_view("css/ossn.default", "css/footer");
        ossn_extend_view("css/ossn.default", "css/loginform");
        ossn_extend_view("css/ossn.default", "css/signupform");
    }
}
ossn_register_callback("ossn", "init", "login_rearr");

but as soon as I activate the cache, the css is ignored.

Replies
German Michael Zülsdorff Replied 11 months ago

Yeah, as often recommended by me:
It's always worth to study the library in question BEFORE using its functions. 💡
In this case line #62/63 of ossn.lib.css.php

German Dominik L Replied 11 months ago

I created mycss.php and not single_css_file.php... 🤦🏼‍♂️

now it seems to work

thank you

Indonesian Arsalan Shah Replied 11 months ago

Where you testing it, And view page source and see if mycss.css file loaded? and does it have any content inside?

https://**/qmclon/main//cache/css/1743797566/view/mycss.css i can see that css is loaded but there is nothing in css file. Did you created file single_css_file.php and added those code inside this file?

German Dominik L Replied 11 months ago

Still not really working

this is the first lines of my css

<?php
$bg_desktop = ossn_site_url("components/LoginRearrange/images/register_form.avif");
$bg_mobile  = ossn_site_url("components/LoginRearrange/images/login_form_mobile.avif");
$bg_reg_mob = ossn_site_url("components/LoginRearrange/images/register_form_mobile.avif");

?>



/* Hintergrundbild */
.ossn-layout-startup-background {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
	background: url("<?php echo $bg_desktop; ?>") no-repeat!important;
    background-size: cover;
    z-index: -1;
}

@media (min-width: 1400px) {
    .ossn-layout-startup-background {
	background: url("<?php echo $bg_desktop; ?>") no-repeat!important;
    }
}

@media (max-width: 768px) {
    .ossn-layout-startup-background {
	background: url("<?php echo $bg_mobile; ?>") no-repeat!important;
        background-position-y: -20px;
        background-attachment: scroll;
    }
}

/* REGISTRIERUNGSFORMULAR */

body.ossn-layout-startup-background:has(#ossn-home-signup){

	background: url("<?php echo $bg_desktop; ?>") no-repeat!important;
}


@media (max-width: 465px) {

body.ossn-layout-startup-background:has(#ossn-home-signup){

	background: url("<?php echo $bg_reg_mob; ?>") no-repeat!important;
}
}

There is a different image for register and login form

I also tried to disable this:

/*.ossn-layout-startup-background {
	min-height: 560px;
	background: url("<?php echo ossn_add_cache_to_url(ossn_theme_url('images/background.jpg'));?>") no-repeat;
	background-size: cover;
}*/

in the core css file but it still doesn't work.

this is my ossn_com.php

<?php
function login_rearr() {
        ossn_new_css('mycss', 'css/single_css_file'); //put all those codes into this file footer, loginform, signupform 
                ossn_load_css('mycss');
     
}
ossn_register_callback('ossn', 'init', 'login_rearr');

and the file is mycss.php in components/LoginRearrange/plugins/default/css

German Dominik L Replied 11 months ago

Thank you! :)

Indonesian Arsalan Shah Replied 11 months ago

Well that is not how it works you are extending global file which is cached and you are trying to extend the file when not loggedin so its ignored

You need to create your own css file and then load it if not loggedin.

<?php
function login_rearr() {
		ossn_new_css('mycss', 'css/single_css_file'); //put all those codes into this file footer, loginform, signupform 
		if(!ossn_isLoggedin()) {
				ossn_load_css('mycss');
		}
}
ossn_register_callback('ossn', 'init', 'login_rearr');